Part Number Hot Search : 
20PFI SQ143N42 WM8580 78030 1N4006E 00152 FDB52N20 39VF80
Product Description
Full Text Search
 

To Download AT32AP7001 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  features ? high performance, low power avr ? 32 32-bit microcontroller ? 210 dmips throughput at 150 mhz ? 16 kb instruction cache and 16 kb data caches ? memory management unit enab ling use of operating systems ? single-cycle risc instruction set including simd and dsp instructions ? java hardware acceleration ? multimedia co-processor ? vector multiplication unit for video acceleration thro ugh color-space conversion (yuv<->rgb), image scalin g and filtering, quarter pixel motion compensation ? multi-hierarchy bus system ? high-performance data transfers on separate buses for increased performance ? data memories ? 32kbytes sram ? external memory interface ? sdram, dataflash ? , sram, multi media card (mmc), secure digital (sd), ? compact flash, smart media, nand flash ? direct memory access controller ? external memory access without cpu intervention ? interrupt controller ? individually maskable interrupts ? each interrupt request has a programm able priority and autovector address ? system functions ? power and clock manager ? crystal oscillator wit h phase-lock-loop (pll) ? watchdog timer ? real-time clock ? 6 multifunction timer/counters ? three external clock inputs, i/o pins, pwm, capture and various counting capabilities ? 4 universal synchronous/asynchrono us receiver/transmitters (usart) ? 115.2 kbps irda modulation and demodulation ? hardware and software handshaking ? 3 synchronous serial protocol controllers ? supports i2s, spi and gene ric frame-based protocols ? two-wire interface ? sequential read/write operations, philips? i2c? compatible ? image sensor interface ? 12-bit data interface for cmos cameras ? universal serial bus (usb) 2.0 high speed (480 mbps) device ? on-chip transceivers with physical interface ? 16-bit stereo audio dac ? sample rates up to 50 khz ? on-chip debug system ? nexus class 3 ? full speed, non-intrusive data and program trace ? runtime control and jtag interface ? package/pins ? AT32AP7001: 208-pin qfp/ 90 gpio pins ? power supplies ? 1.65v to1.95v vddcore ? 3.0v to 3.6v vddio 32015a-avr32-02/07 avr ? 32 32-bit microcontroller AT32AP7001 preliminary
2 32015a-avr32-02/07 AT32AP7001 1. part description the AT32AP7001 is a complete system-on-chip application processor with an avr32 risc processor achieving 210 dmips running at 150 mhz. avr32 is a high-performance 32-bit risc microprocessor core, designed for cost-sensitive embedded applications, with particular empha- sis on low power consumption, high code density and high application performance. AT32AP7001 implements a memory management unit (mmu) and a flexible interrupt controller supporting modern operating systems and real-time operating systems. the processor also includes a rich set of dsp and simd instructio ns, specially designed fo r multimedia and telecom applications. AT32AP7001 incorporates sram memories on-chip for fast and secure access. for applica- tions requiring additional memory, external 16-bit sram is accessible. additionally, an sdram controller provides off-chip volat ile memory access as well as cont rollers for all industry standard off-chip non-volatile memories, like compact flash, multi media card (mmc), secure digital (sd)-card, smartcard, nand flash and atmel dataflash?. the direct memory access controller for all the serial peripherals enables data transfer between memories without processor intervention. this reduces the processor overhead when transfer- ring continuous and large data streams between modules in the mcu. the timer/counters includes three identical 16-bit timer/counter channels. each channel can be independently programmed to perform a wide range of functions including frequency measure- ment, event counting, interval measurement, pulse generation, delay timing and pulse width modulation. a pixel co-processor provides color space conv ersions for images and video, in addition to a wide variety of hardware filter support synchronous serial controllers provide easy ac cess to serial communication protocols, audio standards like ac'97, i2s, i2c? and various spi modes. the modules support frame-based pro- tocols, like voip sip protocols. the java hardware acceleration implementation in avr32 allows for a very high-speed java byte-code execution. avr32 implements java in structions in hardware, reusing the existing risc data path, which allows for a near-zero hardware overhead and cost with a very high performance. the image sensor interface supports cameras with up to 12-bit data buses and connects directly to the lcd interface through a separate bus. ps2 connectivity is provided for standa rd input devices like mice and keyboards. AT32AP7001 integrates a class 3 nexus 2.0 on -chip debug (ocd) system, with non-intrusive real-time trace, full-speed read/write memory access in addition to basic runtime control. the c-compiler is closely linked to the architecture and is able to utilize code optimization fea- tures, both for size and speed.
3 32015a-avr32-02/07 AT32AP7001 2. signals description the following table gives details on the signal name classified by peripheral. the pinout multi- plexing of these signals is given in the perip heral muxing table in the peripherals chapter. table 2-1. signal description list signal name function type active level comments power avddpll pll power supply power 1.65 to 1.95 v avddusb usb power supply power 1.65 to 1.95 v avddosc oscillator power supply power 1.65 to 1.95 v vddcore core power supply power 1.65 to 1.95 v vddio i/o power supply power 3.0 to 3.6v agndpll pll ground ground agndusb usb ground ground agndosc oscillator ground ground gnd ground ground clocks, oscillators, and pll?s xin0, xin1, xin32 crystal 0, 1, 32 input analog xout0, xout1, xout32 crystal 0, 1, 32 output analog pll0, pll1 pll 0,1 filter pin analog jtag tck test clock input tdi test data in input tdo test data out output tms test mode select input trst_n test reset input low auxiliary port - aux mcko trace data output clock output mdo0 - mdo5 trace data output output mseo0 - mseo1 trace frame control output evti_n event in input low
4 32015a-avr32-02/07 AT32AP7001 evto_n event out output low power manager - pm gclk0 - gclk4 generic clock pins output oscen_n oscillator enable input low reset_n reset pin input low wake_n wake pin input low external interrup t module - eim extint0 - extint3 external interrupt pins input nmi_n non-maskable interrupt pin input low ac97 controller - ac97c sclk ac97 clock signal input sdi ac97 receive signal output sdo ac97 transmit signal output sync ac97 frame synchronization signal input dac - dac data0 - data1 d/a data out output datan0 - datan1 d/a inverted data out output external bus interface - ebi addr0 - addr25 address bus output cas column signal output low cfce1 compact flash 1 chip enable output low cfce2 compact flash 2 chip enable output low cfrnw compact flash read not write output data0 - data31 data bus i/o nandoe nand flash output enable output low nandwe nand flash write enable output low ncs0 - ncs5 chip select output low nrd read signal output low table 2-1. signal description list signal name function type active level comments
5 32015a-avr32-02/07 AT32AP7001 nwait external wait signal input low nwe0 write enable 0 output low nwe1 write enable 1 output low nwe3 write enable 3 output low ras row signal output low sda10 sdram address 10 line output sdck sdram clock output sdcke sdram clock enable output sdcs sdram chip select output low sdwe sdram write enable output low image sensor interface - isi data0 - data11 image sensor data input hsync horizontal synchronization input pclk image sensor data clock input vsync vertical synchronization input mulitmedia card interface - mmci clk multimedia card clock output cmd0 - cmd1 multimedia card command i/o data0 - data7 multimedia card data i/o parallel input/output 2 - pioa, piob, pioc, piod, pioe pa0 - pa31 parallel i/o controller pioa i/o pb0 - pb30 parallel i/o controller piob i/o pc0 - pc31 parallel i/o controller pioc i/o pd0 - pd17 parallel i/o controller piod i/o pe0 - pe26 parallel i/o controller pioe i/o ps2 interface - psif clock0 - clock1 ps2 clock input data0 - data1 ps2 data i/o table 2-1. signal description list signal name function type active level comments
6 32015a-avr32-02/07 AT32AP7001 serial peripheral in terface - spi0, spi1 miso master in slave out i/o mosi master out slave in i/o npcs0 - npcs3 spi peripheral chip select i/o low sck clock output synchronous serial contro ller - ssc0, ssc1, ssc2 rx_clock ssc receive clock i/o rx_data ssc receive data input rx_frame_sync ssc receive frame sync i/o tx_clock ssc transmit clock i/o tx_data ssc transmit data output tx_frame_sync ssc transmit frame sync i/o dma controller - dmac dmarq0 - dmarq3 dma requests input timer/counter - timer0, timer1 a0 channel 0 line a i/o a1 channel 1 line a i/o a2 channel 2 line a i/o b0 channel 0 line b i/o b1 channel 1 line b i/o b2 channel 2 line b i/o clk0 channel 0 external clock input input clk1 channel 1 external clock input input clk2 channel 2 external clock input input two-wire interface - twi scl serial clock i/o sda serial data i/o universal synchronous asynchronous receiver transmitter - usart0, usart1, usart2, usart3 table 2-1. signal description list signal name function type active level comments
7 32015a-avr32-02/07 AT32AP7001 clk clock i/o cts clear to send input rts request to send output rxd receive data input txd transmit data output pulse width modulator - pwm pwm0 - pwm3 pwm output pins output universal serial bus device - usb ddm usb device port data - analog ddp usb device port data + analog vbg usb bandgap analog connected to a 6810 ohm 0.5% resistor to gound and a 10 pf capacitor to ground. table 2-1. signal description list signal name function type active level comments
8 32015a?avr32?02/07 AT32AP7001 3. power considerations 3.1 power supplies the AT32AP7001 has several types of power supply pins: ? vddcore pins: power the core , memories, and peripherals. voltage is 1.8v nominal. ? vddio pins: power i/o lines. voltage is 3.3v nominal. ? vddpll pin: powers the pll. voltage is 1.8v nominal. ? vddusb pin: powers the usb. voltage is 1.8v nominal. ? vddosc pin: powers the oscillat ors. voltage is 1.8v nominal. the ground pins gnd are common to vddcore and vddio. the ground pin for vddpll is gndpll, and the gnd pin for vddosc is gndosc. see ?electrical characteristics? on page 770 for power consumption on the various supply pins. 3.2 power supply connections special considerations should be made when connecting the power and ground pins on a pcb. figure 3-1 shows how this should be done. figure 3-1. connecting analog power supplies avddusb avddpll avddosc agndusb agndpll agndosc vddcore vcc_1v8 3.3uh c54 0.10u c55 0.10u c56 0.10u
9 32015a?avr32?02/07 AT32AP7001 4. package and pinout 4.1 avr32ap7001 figure 4-1. 208 qfp pinout. 152 53 104 105 156 157 208 table 4-1. qfp-208 package pinout 1 gnd 53 gnd 105 gnd 157 gnd 2 pe17 54 pa23 106 px13 158 pb10 3 pe18 55 pa24 107 px14 159 pb11 4 px47 56 xin1 108 px15 160 pb12 5 px48 57 xout1 109 px16 161 pb13 6 px49 58 avddusb 110 px17 162 pb14 7 px50 59 agndusb 111 px34 163 pb15 8 px51 60 vddio 112 px35 164 pb16 9 vddio 61 fsdm 113 px36 165 pb17 10 px32 62 fsdp 114 px37 166 pb18 11 px33 63 gnd 115 px38 167 pb19 12 px00 64 gnd 116 px18 168 pb20 13 px01 65 hsdm 117 px19 169 pb21 14 px02 66 hsdp 118 px20 170 pb22 15 px03 67 vddcore 119 px21 171 pb23 16 px04 68 gnd 120 px22 172 vddcore 17 px05 69 gnd 121 px23 173 gnd 18 vddcore 70 vbg 122 px24 174 gnd 19 gnd 71 vddio 123 px25 175 pa06 20 tdo 72 pa25 124 px26 176 pa07 21 tck 73 pa26 125 vddio 177 vddio
10 32015a?avr32?02/07 AT32AP7001 22 tms 74 pa27 126 px27 178 vddio 23 tdi 75 pa28 127 px28 179 oscen_n 24 trst_n 76 pa29 128 px29 180 xin32 25 evti_n 77 pa30 129 px30 181 xout32 26 reset_n 78 pa31 130 px31 182 agndosc 27 pa00 79 wake_n 131 vddcore 183 avddosc 28 pa01 80 pb26 132 gnd 184 pll1 29 pa02 81 pb27 133 gnd 185 xin0 30 pa03 82 pb28 134 pe26 186 xout0 31 pa04 83 px53 135 px39 187 agndpll 32 pa05 84 px52 136 vddcore 188 avddpll 33 pb24 85 px41 137 gnd 189 pll0 34 pb25 86 gnd 138 px40 190 pe00 35 pa08 87 pe25 139 px42 191 pe01 36 vddio 88 pe24 140 px43 192 pe02 37 gnd 89 pe23 141 px44 193 pe03 38 pa09 90 pe22 142 px45 194 pe04 39 pa10 91 pe21 143 px46 195 pe05 40 pa11 92 pe20 144 pb00 196 pe06 41 pa12 93 pe19 145 pb01 197 pe07 42 pa13 94 px06 146 pb02 198 pe08 43 pa14 95 px07 147 pb03 199 pe09 44 pa15 96 px08 148 pb04 200 pe10 45 pa16 97 px09 149 pb05 201 pe11 46 pa17 98 px10 150 pb06 202 pe12 47 pa18 99 px11 151 pb07 203 pe13 48 pa19 100 pb29 152 pb08 204 pe14 49 pa20 101 pb30 153 pb09 205 pe15 50 pa21 102 px12 154 pc16 206 pe16 51 pa22 103 pc00 155 pc17 207 no connect 52 vddio 104 vddio 156 vddio 208 gnd table 4-1. qfp-208 package pinout (continued)
11 32015a?avr32?02/07 AT32AP7001 5. blockdiagram figure 5-1. blockdiagram data[11..0] hsync vsync pclk ap cpu nexus class 3 ocd instr cache data cache timer/counter 0/1 interrupt controller real time counter peripheral dma controller intram0 intram1 hsb-pb bridge b hsb-pb bridge a s m m m s s s m external interrupt controller high speed bus matrix parallel input/output controllers pixel coprocessor parallel input/output controllers reset_n pa pb pc pd pe a [ 2 . . 0 ] b [ 2 . . 0 ] clk[2..0] e x t i n t [ 7 . . 0 ] k p s [ 7 . . 0 ] nmi_n g c l k [ 3 . . 0 ] xin32 xout32 xin0 xout0 pa pb pc pd pe external bus interface (sdram & static memory controller & ecc) ras, cas, sdwe, nandoe, nandwe, sdck, sdcke, nwe3, nwe1, nwe0, nrd, ncs[3,1,0], addr[22..0] sdcs, ncs[5,4,2] cfrnw, cfce1, cfce2, addr[23..25] nwait data[15..0] usb interface dma d- d+ 32 khz osc osc0 pll0 ps2 interface serial peripheral interface 0/1 two-wire interface pdc miso, mosi npcs[3..1] scl sda usart0 usart1 usart2 usart3 pdc rxd txd clk rts, cts synchronous serial controller 0/1/2 pdc tx_clock, tx_frame_sync rx_data tx_data rx_clock, rx_frame_sync watchdog timer xin1 xout1 osc1 pll1 sck jtag interface mcko mdo[5..0] mseo[1..0] evti_n evto_n tck tdo tdi tms power manager reset controller sleep controller clock controller clock generator configuration registers bus memory management unit pb pb hsb hsb pba pbb npcs0 m s clock[1..0] data[1..0] hsb-hsb bridge trst_n data[31..16] oscen_n pll0 pll1 dma controller s m m audio bitstream dac dma multimedia card interface dma ac97 controller dma s c l k s d i s s y n c s d o c l k cmd data[7..0] d a t a 0 d a t a 1 d a t a 0 n d a t a 1 n pulse width modulation controller pwm0 pwm1 pwm2 pwm3 image sensor interface m
12 32015a?avr32?02/07 AT32AP7001 5.1 processor and architecture 5.1.1 avr32ap cpu ? 32-bit load/store avr32b risc architecture. ? up to 15 general-purpose 32-bit registers. ? 32-bit stack pointer, program counter and link register reside in register file. ? fully orthogonal instruction set. ? privileged and unprivileged modes enabling efficient and secure operating systems. ? innovative instruction set together with variable instruction length ensu ring industry leading code density. ? dsp extention with saturating arithmetic, and a wide variet y of multiply instructions. ? simd extention for media applications. ? 7 stage pipeline allows one instruction per clock cycle for most instructions. ? java hardware acceleration. ? byte, half-word, word and double word memory access. ? unaligned memory access. ? shadowed interrupt context for int3 an d multiple interrupt priority levels. ? dynamic branch prediction and return address stac k for fast change-of-flow. ? coprocessor interface. ? full mmu allows for operating systems with memory protection. ? 16kbyte instruction and 16kbyte data caches. ? virtually indexed, physically tagged. ? 4-way associative. ? write-through or write-back. ? nexus class 3 on-chip debug system. ? low-cost nanotrace supported. 5.1.2 pixel coprocessor (pico) ? coprocessor coupled to the avr3 2 cpu core through the tcb bus. ? three parallel vector multiplicati on units (vmu) where each unit can: ? multiply three pixel componen ts with three coefficients. ? add the products from the multiplications together. ? accumulate the result or add an o ffset to the sum of the products. ? can be used for accelerating: ? image color space conversion. ?configurable conver sion coefficients. ? supports packed and planar input and output formats. ? supports subsampled input color spaces (i.e 4:2:2, 4:2:0). ? image filtering/scaling. ? configurable filter coefficients. ? throughput of one sample per cycle for a 9-tap fir filter. ? can use the built-in accumulator to extend the fir filter to more than 9-taps. ? can be used for bilinear/bicubic interpolations. ? mpeg-4/h.264 quarter pi xel motion compensation. ? flexible input pixel selector. ? can operate on numerous different image storage formats. ? flexible output pixel inserter. ? scales and saturates the results back to 8-bit pixel values.
13 32015a?avr32?02/07 AT32AP7001 ? supports packed and planar output formats. ? configurable coefficien ts with flexible fixe d-point representation. 5.1.3 debug and test system ? ieee1149.1 compliant jtag and boundary scan ? direct memory access and programming capabilities through jtag interface ? extensive on-chip debug features in compliance with ieee-isto 5001-2003 (nexus 2.0) class 3 ? auxiliary port for high-speed trace information ? hardware support for 6 program and 2 data breakpoints ? unlimited number of softw are breakpoints supported ? advanced program, data, ownership, and watchpoint trace supported 5.1.4 dma controller ? 2 hsb master interfaces ? 3 channels ? software and hardware handshaking interfaces ? 11 hardware handshaking interfaces ? memory/non-memory periph erals to memory/non-mem ory peripherals transfer ? single-block dma transfer ? multi-block dma transfer ? linked lists ? auto-reloading ? contiguous blocks ? dma controller is always the flow controller ? additional features ? scatter and gather operations ? channel locking ? bus locking ? fifo mode ? pseudo fly-by operation 5.1.5 peripheral dma controller ? transfers from/to peripheral to/from any memory space without interven tion of the processor. ? next pointer support, forbids strong real -time constraints on buffer management. ? eighteen channels ? two for each usart ? two for each serial synchronous controller ? two for each serial peripheral interface 5.1.6 bus system ? hsb bus matrix with 10 masters and 8 slaves handled ? handles requests from the cpu icache, cpu d cache, hsb bridge, hisi, usb 2.0 controller, dma controller 0, dma controller 1, and to intern al sram 0, internal sram 1, pb a, pb b, ebi and, usb.
14 32015a?avr32?02/07 AT32AP7001 ? round-robin arbitration (three modes supported: no default master, last accessed default master, fixed default master) ? burst breaking with slot cycle limit ? one address decoder provided per master ? 2 peripheral buses allowing each bu s to run on different bus speeds. ? pb a intended to run on low clock speed s, with peripherals co nnected to the pdc. ? pb b intended to run on higher clock spee ds, with peripherals connected to the dmac. ? hsb-hsb bridge providing a low-speed hs b bus running at the same speed as pba ? allows pdc transfers between a low-speed pb bus and a bus matrix of higher clock speeds an overview of the bus system is given in figure 5-1 on page 11 . all modules connected to the same bus use the same clock, but the clock to each module can be individually shut off by the power manager. the figure identifies the number of master and slave interfaces of each module connected to the hsb bus, and which dma controller is connected to which peripheral.
15 32015a?avr32?02/07 AT32AP7001 6. i/o line considerations 6.1 jtag pins the tms, tdi and tck pins have pull-up resistors. tdo is an output, driven at up to vddio, and have no pull-up resistor. the trst_n pin is used to initialize the embedded jtag tap controller when asserted at a low level. it is a schmitt input and integrates permanent pull-up resistor to vddio, so that it can be left unconnected for normal operations. 6.2 wake_n pin the wake_n pin is a schmitt trig ger input integr ating a permanent pull-up resistor to vddio. 6.3 reset_n pin the reset_n pin is a schmitt input and integrates a permanent pull-up resistor to vddio. as the product integrat es a power-on reset cell, the reset_n pin can be left unconnected in case no reset from the system needs to be applied to the product. 6.4 evti_n pin the evti_n pin is a schmitt input and integrates a non-programmable pull-up resistor to vddio. 6.5 twi pins when these pins are used for twi, the pins are open-drain outputs with slew-rate limitation and inputs with inputs with spike-filtering. when used as gpio-pins or used for other peripherals, the pins have the same characteristics as pio pins. 6.6 pio pins all the i/o lines integrate a programmable pull-up resistor . programming of this pull-up resistor is performed independently for each i/o line through the pio controllers. after reset, i/o lines default as inputs with pull-up resistors enabled, ex cept when indicated otherwise in the column ?reset state? of the pio controller multiplexing tables.
16 32015a?avr32?02/07 AT32AP7001 7. avr32 ap cpu this chapter gives an overview of the avr32 ap cpu. avr32 ap is an implementation of the avr32 architecture. a summary of the programming model, instruction set, caches and mmu is presented. for further details, see the avr32 architecture manual and the avr32 ap technical reference manual . 7.1 avr32 architecture avr32 is a new, high-performance 32-bit risc mi croprocessor architectu re, designed for cost- sensitive embedded applications, with particul ar emphasis on low power consumption and high code density. in addition, the instruction set architecture has been tuned to allow a variety of microarchitectures, enabling the avr32 to be im plemented as low-, mid- or high-performance processors. avr32 extends the avr family into the world of 32- and 64-bit applications. through a quantitative approach, a large set of industry recognized benchmarks has been com- piled and analyzed to achieve the best code density in its class. in addition to lowering the memory requirements, a compact code size also contributes to the core?s low power characteris- tics. the processor supports byte and half-word data types without penalty in code size and performance. memory load and store operations are provided for byte, half-word, word and double word data with automatic sign- or zero extension of half-word and byte data. in order to reduce code size to a minimum, so me instructions have multiple addressing modes. as an example, instructions with immediates often have a compact format with a smaller imme- diate, and an extended format with a larger immediate. in this way, the compiler is able to use the format giving the smallest code size. another feature of the instruction set is that frequently used instructions, like add, have a com- pact format with two operands as well as an extended format with three operands. the larger format increases performance, allowing an addition and a data move in the same instruction in a single cycle. load and store instructions have seve ral different formats in order to reduce code size and speed up execution. the register file is organized as sixteen 32-bi t registers and includes the program counter, the link register, and the stack pointer. in addition, register r12 is designed to hold return values from function calls and is used im plicitly by some instructions. 7.2 the avr32 ap cpu avr32 ap targets high-performance applications, and provides an advanced ocd system, effi- cient data and instruction caches, and a full mmu. figure 7-1 on page 17 displays the contents of avr32 ap.
17 32015a?avr32?02/07 AT32AP7001 figure 7-1. overview of the avr32 ap cpu 7.2.1 pipeline overview avr32 ap is a pipelined processor with seven pipe line stages. the pipeline has three subpipes, namely the multiply pipe, the execute pipe and the data pipe. these pipelines may execute dif- ferent instructions in parallel. instructions are issued in order, but may complete out of order (ooo) since the subpipes may be stalled individ ually, and certain operations may use a subpipe for several clock cycles. figure 7-2 on page 18 shows an overview of the avr32 ap pipeline stages. avr32 cpu pipeline with java accelerator dcache controller hsb master icache controller hsb master 32-entry tlb 8-entry utlb 4-entry utlb mmu high speed bus high speed bus cache ram interface cache ram interface btb ram interface tightly coupled bus ocd system ocd interface reset control reset interface interrupt controller interface jtag control jtag interface
18 32015a?avr32?02/07 AT32AP7001 figure 7-2. the avr32 ap pipeline .the follwing abbreviations are used in the figure: ? if1, if2 - instruction fetch stage 1 and 2 ? id - instruction decode ? is - instruction issue ? a1, a2 - alu stage 1 and 2 ? m1, m2 - multiply stage 1 and 2 ? da - data address calculation stage ? d - data cache access ? wb - writeback 7.2.2 avr32b microarchitecture compliance avr32 ap implements an avr32b microarchitec ture. the avr32b microarchitecture is tar- geted at applications where interrupt latency is important. the avr32b therefore implements dedicated registers to hold the status register and return address for interrupts, exceptions and supervisor calls. this information does not need to be written to the stack, and latency is there- fore reduced. additionally, avr32b allows hardware shadowing of the registers in the register file. the scall , rete and rets instructions use the dedicated return status registers and return address registers in their operation. no stack accesses are performed by these instructions. 7.2.3 java support avr32 ap provides java hardware acceleration in the form of a java virtual machine hardware implementation. refer to the avr32 java technical reference manual for details. 7.2.4 memory management avr32 ap implements a full mmu as specified by the avr32 architecture. the page sizes pro- vided are 1k, 4k, 64k and 1m. a 32-entry fully-associative common tlb is implemented, as well as a 4-entry micro-itlb and 8-entry micro-dtlb. instruction and data accesses perform lookups in the micro-tlbs. if the access misses in the mi cro-tlbs, an access in the common tlb is per- formed. if this access misses, a page miss exception is issued. if2 id is a1 m1 m2 d wb prefetch unit decode unit alu pipe multiply pipe load-store pipe da a2 if1
19 32015a?avr32?02/07 AT32AP7001 7.2.5 caches and write buffer avr32 ap implements 16k data and 16k instruction caches. the caches are 4-way set asso- ciative. each cache has a 32-bit system bus master interface connecting it to the bus. the instruction cache has a 32-bit interface to the fetch pipeline stage, and the data cache has a 64- bit interface to the load-store pipeline. the cac hes use a least recently used allocate-on-read- miss replacement policy. the caches are virtually tagged, physically indexed, avoiding the need to flush them on task switch. the caches provide locking on a per-line basis, allowing code and data to be permanently locked in the caches for timing-critical code. t he data cache also allows prefetching of data using the pref instruction. accesses to the instruction and data caches ar e tagged as cacheable or uncacheable on a per- page basis by the mmu. data cache writes are tagged as write-through or writeback on a per- page basis by the mmu. the data cache has a 32-byte combining write buffe r, to avoid stalling the cpu when writing to external memory. writes are tagged as bufferable or unbufferable on a per-page basis by the mmu. bufferable writes to sequential addresses are placed in the buffer, allowing for example a sequence of byte writes from the cpu to be combined into word transfers on the bus. a sync instruction is provided to explicitly flush the write buffer. 7.2.6 unaligned reference handling avr32 ap has hardware support for performing unaligned memory accesses. this will reduce the memory footprint needed by some applicatio ns, as well as speed up other applications oper- ating on unaligned data. avr32 ap is able to perform certain word-sized load and store instructions of any alignment, and word-aligned st.d and ld.d . any other unaligned memory a ccess will cause an mmu address exception. all coprocessor memory access inst ructions require word-a ligned pointers. double- word-sized accesses with word-aligned pointers will automatically be performed as two word- sized accesses. the following table shows the instructions with support for unaligned addresses. all other instructions require aligned addresses. ac cessing an unaligned address may require several clock cycles, refer to the avr32 ap technical reference manual for details. table 7-1. instructions with unaligned reference support instruction supported alignment ld.w any st.w any lddsp any lddpc any stdsp any ld.d word st.d word all coprocessor memory access instruction word
20 32015a?avr32?02/07 AT32AP7001 7.2.7 unimplemented instructions the following instructions are unimplemented in avr32 ap, and will cause an unimplemented instruction exception if executed: ?mems ?memc ?memt 7.2.8 exceptions and interrupts avr32 ap incorporates a powerful exception handling scheme. the different exception sources, like illegal op-code and external interrup t requests, have different priority levels, ensur- ing a well-defined behavior when multiple except ions are received simu ltaneously. additionally, pending exceptions of a higher priority class ma y preempt handling of ongoing exceptions of a lower priority class. each priority class has dedicated registers to keep the return address and status register thereby removing the need to perform time-consuming memory operations to save this information. there are four levels of external interrupt req uests, all executing in their own context. the int3 context provides dedicated shadow registers ensuring low latency for these interrupts. an inter- rupt controller does the priority handling of th e external interrupts and provides the autovector offset to the cpu. the addresses and priority of si multaneous events are shown in table 7-2 on page 21 .
21 32015a?avr32?02/07 AT32AP7001 table 7-2. priority and handler addresses for events priority handler address name event source stored return address 1 0xa000_0000 reset external input undefined 2 provided by ocd system ocd stop cpu ocd system first non-compl eted instruction 3 evba+0x00 unrecoverable exception int ernal pc of offending instruction 4 evba+0x04 tlb multiple hit internal signal pc of offending instruction 5 evba+0x08 bus error data fetch data bu s first non-completed instruction 6 evba+0x0c bus error instruction fetch dat a bus first non-completed instruction 7 evba+0x10 nmi external input first non-completed instruction 8 autovectored interrupt 3 request external input first non-completed instruction 9 autovectored interrupt 2 request external input first non-completed instruction 10 autovectored interrupt 1 request external input first non-completed instruction 11 autovectored interrupt 0 request external input first non-completed instruction 12 evba+0x14 instruction address itlb pc of offending instruction 13 evba+0x50 itlb miss itlb pc of offending instruction 14 evba+0x18 itlb protection itlb pc of offending instruction 15 evba+0x1c breakpoint ocd system firs t non-completed instruction 16 evba+0x20 illegal opcode instructio n pc of offending instruction 17 evba+0x24 unimplemented instruction instr uction pc of offending instruction 18 evba+0x28 privilege violation instruc tion pc of offending instruction 19 evba+0x2c floating-point fp hardware pc of offending instruction 20 evba+0x30 coprocessor absent instruct ion pc of offending instruction 21 evba+0x100 supervisor call instru ction pc(supervisor call) +2 22 evba+0x34 data address (read) dtlb pc of offending instruction 23 evba+0x38 data address (write) dtl b pc of offending instruction 24 evba+0x60 dtlb miss (read) dtlb pc of offending instruction 25 evba+0x70 dtlb miss (write) dtlb pc of offending instruction 26 evba+0x3c dtlb protecti on (read) dtlb pc of offending instruction 27 evba+0x40 dtlb protection (write) d tlb pc of offending instruction 28 evba+0x44 dtlb modified dtlb pc of offending instruction
22 32015a?avr32?02/07 AT32AP7001 7.3 programming model 7.3.1 register file configuration the avr32b architecture specifies that the ex ception contexts may have a different number of shadowed registers in different implementations. figure 7-3 on page 22 shows the model used in avr32 ap. figure 7-3. the avr32 ap register file 7.3.2 status register configuration the status register (sr) is splitted into two halfwords, one upper and one lower, see figure 7-4 on page 22 and figure 7-5 on page 23 . the lower word contains the c, z, n, v and q condition code flags and the r, t and l bits, while the upper halfword contains information about the mode and state the processor executes in. refer to the avr32 architecture manual for details. figure 7-4. the status register high halfword application bit 0 supervisor bit 31 pc sr int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 bit 0 bit 31 pc sr r12 int0pc fintpc int1pc smpc r7 r5 r6 r4 r11 r9 r10 r8 r3 r1 r2 r0 rsr_int0 sr rsr_ex sr sp_app sp_sys rsr_nmi sr r12 r11 r9 r10 r8 bit 0 bit 31 pc int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 bit 0 bit 31 pc fintpc smpc r7 r5 r6 r4 r3 r1 r2 r0 bit 0 bit 31 pc lr_int3 r12_int3 r11_int3 r9_int3 r10_int3 r8_int3 sp_sys sp_sys sp_sys r12 r11 r9 r10 r8 bit 0 bit 31 pc int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 sp_sys r12 r11 r9 r10 r8 bit 0 bit 31 pc int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 sp_sys r12 r11 r9 r10 r8 bit 0 bit 31 pc int0pc fintpc int1pc smpc r7 r5 r6 r4 r3 r1 r2 r0 sp_sys r12 r11 r9 r10 r8 rsr_int1 sr rsr_int2 sr rsr_int3 sr int0 int1 int2 int3 exception nmi fintpc smpc r7 r5 r6 r4 r3 r1 r2 r0 r12 r11 r9 r10 r8 lr lr lr lr lr lr lr rsr_sup rar_int0 rar_ex rar_nmi rar_int1 rar_int2 rar_int3 rar_sup bit 31 0 0 0 bit 16 interrupt level 0 mask interrupt level 1 mask interrupt level 3 mask interrupt level 2 mask 1 0 0 0 0 1 1 0 0 0 0 0 0 reserved fe i0m gm m1 j d m0 em i2m dm - m2 lc 1 - initial value bit name i1m mode bit 0 mode bit 1 h mode bit 2 reserved debug state - i3m java state exception mask global interrupt mask debug state mask java handle reserved
23 32015a?avr32?02/07 AT32AP7001 figure 7-5. the status register low halfword 7.3.3 processor states 7.3.3.1 normal risc state the avr32 processor supports several diff erent execution contexts as shown in table 7-3 on page 23 . mode changes can be made under software control, or can be caused by external interrupts or exception processing. a mode can be interrupted by a higher priority mode, but never by one with lower priority. nested exceptions can be supported with a minimal software overhead. when running an operating syste m on the avr32, user processes will typically execute in the application mode. the programs executed in this mode are restricted from executing certain instructions. furthermore, most system registers together with the upper halfword of the status register cannot be accessed. protected memory areas are also not available. all other operating modes are privileged and are collectively called system modes. they have full access to all priv- ileged and unprivileged re sources. after a reset, the proc essor will be in su pervisor mode. 7.3.3.2 debug state the avr32 can be set in a debug state, which allows implementation of software monitor rou- tines that can read out and alter system information for use during application development. this implies that all system and application regist ers, including the status registers and program counters, are accessible in debug state. th e privileged instructions are also available. bit 15 bit 0 reserved carry zero sign 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - t r bit name initial value 0 0 l q v n z c - overflow saturation - - - lock register remap enable scratch table 7-3. overview of execution modes, their priorities and pr ivilege levels. priority mode securi ty description 1 non maskable interrupt privileged non maskable high priority interrupt mode 2 exception privileged execute exceptions 3 interrupt 3 privileged general purpose interrupt mode 4 interrupt 2 privileged general purpose interrupt mode 5 interrupt 1 privileged general purpose interrupt mode 6 interrupt 0 privileged general purpose interrupt mode n/a supervisor privileged runs supervisor calls n/a application unprivileged normal program execution mode
24 32015a?avr32?02/07 AT32AP7001 all interrupt levels are by default disabled when debug state is entered, but they can individually be switched on by the monitor routine by clearing the respective mask bit in the status register. debug state can be entered as described in the avr32 ap technical reference manual . debug state is exited by the retd instruction. 7.3.3.3 java state avr32 ap implements a java extension module (jem). the processor can be set in a java state where normal risc operations are suspended. refer to the avr32 java technical refer- ence manual for details.
25 32015a?avr32?02/07 AT32AP7001 8. pixel coprocessor (pico) 8.1 features ? coprocessor coupled to the avr3 2 cpu core through the tcb bus. ? three parallel vector multiplicati on units (vmu) where each unit can: ? multiply three pixel componen ts with three coefficients. ? add the products from the multiplications together. ? accumulate the result or add an o ffset to the sum of the products. ? can be used for accelerating: ? image color space conversion. ?configurable conver sion coefficients. ? supports packed and planar input and output formats. ? supports subsampled input color spaces (i.e 4:2:2, 4:2:0). ? image filtering/scaling. ? configurable filter coefficients. ? throughput of one sample per cycle for a 9-tap fir filter. ? can use the built-in accumulator to extend the fir filter to more than 9-taps. ? can be used for bilinear/bicubic interpolations. ? mpeg-4/h.264 quarter pi xel motion compensation. ? flexible input pixel selector. ? can operate on numerous different image storage formats. ? flexible output pixel inserter. ? scales and saturates the results back to 8-bit pixel values. ? supports packed and planar output formats. ? configurable coefficien ts with flexible fixe d-point representation. 8.2 description the pixel coprocessor (pico) is a coprocesso r coupled to the avr32 cpu through the tcb (tightly coupled bus) interface. the pico consists of three ve ctor multiplication units (vmu0, vmu1, vmu2), an input pixel selector and an output pixel inserter. each vmu can perform a vector multiplication of a 1x3 12-bit coefficient vector with a 3x1 8-bit pixel vector. in addition a 12-bit offset can be added to the result of this vector multiplication. the pico can be used for transforming the pixel components in a given color space (i.e. rgb, ycrcb, yuv) to any othe r color space as long as the transformation is linear. the flexibility of the input pixel selector and output pixel insertio n logic makes it easy to efficiently support dif- ferent pixel storage formats with regards to issues such as byte ordering of the color components, if the color components constituting an image are packed/interleaved or stored as separate images or if any of the color components are subsampled. the three vector multiplication units can also be connected together to form one large vector multiplier which can perform a vector multiplication of a 1x9 12-bit coefficient vector with a 9x1 8- bit pixel vector. this can be used to implement fir filters, bilinear interpolations filters for smoothing/scaling images etc. by allowing the outputs from the vector multiplication units to accumulate it is also possible to extend the order of the filter to more than 9-taps. the results from the vmus are scaled and saturated back to unsigned 8-bit pixel values in the output pixel inserter. the pico is divided into three pipeline stages with a throughput of one operation per cpu clock cycle.
26 32015a?avr32?02/07 AT32AP7001 8.3 block diagram figure 8-1. pixel coprocessor block diagram 8.4 vector multiplication unit (vmu) each vmu consists of three mult ipliers used for multiplying uns igned 8-bit pixel components with signed 12-bit coefficients.the result from each multiplication is a 20-bit signed number that is inpix0 vmu0_out input pixel selector vmu0 add vmu0_in0 vmu0_in1 vmu0_in2 inpix1 inpix2 coeff0_0 coeff0_1 coeff0_2 offset0 vmu1_out vmu1 vmu1_in0 vmu1_in1 vmu1_in2 coeff1_0 coeff1_1 coeff1_2 offset1 vmu2_out vmu2 vmu2_in0 vmu2_in1 vmu2_in2 coeff2_0 coeff2_1 coeff2_2 offset2 outpix0 outpix1 outpix2 output pixel inserter pipeline stage 1 pipeline stage 2 pipeline stage 3
27 32015a?avr32?02/07 AT32AP7001 input to a 22-bit vector adder along with an offset as shown in figure 8-2 on page 27 . the oper- ation is equal to the offsetted vector multiplication given in the following equation: figure 8-2. inside vmu n ( n {0,1,2}) 8.5 input pixel selector the input pixel selector uses the ism (input selection mode) field in the config register and the three input pixel source addresses given in the pico operation instructions to decide which pixels to select for inputs to the vmus. 8.5.1 transformation mode when the input selection mode is set to transformation mode the input pixel source addresses inx, iny and inz directly maps to three pixels in the inpix n registers. these three pixels are then input to each of the vmus. the following expression then represents what is computed by the vmus in transformation mode: 8.5.2 horizontal filter mode in horizontal filter mode the input pixel source addresses inx, iny and inz represents the base pixel address of a pixel triplet. the pixel triplet {in(x), in(x+1), in(x+2)} is input to vmu0, the pixel triplet {in(y), in(y+1), in(y+2 )} is input to vmu1 and the pixe l triplet {in(z), in(z+1), in(z+2)} is input to vmu2. figure 8-3 on page 28 shows how the pixel triplet is found by taking the pixel addressed by the base address and following the arrow to find the next two pixels which makes up the triplet. vmu_out coeff0 coeff1 coeff2 vmu_in0 vmu_in1 vmu_in2 offset + = multiply vector adder multiply multiply vmu n offset n coeff n _1 coeff n _2 coeff n _0 vmu n _in0 vmu n _in1 vmu n _in2 vmu n _out vmu0_out vmu1_out vmu2_out coeff0_0 coeff0_1 coeff0_2 coeff1_0 coeff1_1 coeff1_2 coeff2_0 coeff2_1 coeff2_2 inx iny inz offset0 or vmu0_out offset1 or vmu1_out offset2 or vmu2_out + =
28 32015a?avr32?02/07 AT32AP7001 figure 8-3. horizontal filter mode pixel addressing the following expression represents what is computed by the vmus in horizontal filter mode: 8.5.3 vertical filter mode in vertical filter mode the input pixel source addresses inx, iny and inz represent the base of a pixel triplet found by following the vertical arrow shown in figure 8-4 on page 28 . the pixel triplet {in(x), in((x+4)%11), in((x+8)%11)} is input to vmu0, the pixel triplet {in(y), in((y+4)%11), in((y+8)%11)} is input to vmu1 and the pixel trip let {in(z), in((z+4)%11), in((z+8)%11)} is input to vmu2. figure 8-4. vertical filter mode pixel addressing inpix0 in0 in1 in2 in3 in4 in5 in6 in7 in8 in9 in10 in11 inpix1 inpix2 vmu0_out coeff0_0 coeff0_1 coeff0_2 in(x+0) in(x+1) in(x+2) offset0 or vmu0_out () + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in(y+0) in(y+1) in(y+2) offset1 or vmu1_out () + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in(z+0) in(z+1) in(z+2) offset2 or vmu2_out () + = inpix0 in0 in1 in2 in3 in4 in5 in6 in7 in8 in9 in10 in11 inpix1 inpix2
29 32015a?avr32?02/07 AT32AP7001 the following expression represents what is computed by the vmus in vertical filter mode: 8.6 output pixel inserter the output pixel inserter uses the oim (output insertion mode) field in the config register and the destination pixel address given in the pico operation instructions to decide which three of the twelve possible out n pixels to write back the scaled a nd saturated results from the vmus to. the 22-bit results from each vmu is first scal ed by performing an arithmetical right shift by coeff_frac_bits in order to remove the fractional part of the results and obtain the integer part. the integer part is then saturated to an unsigned 8-bit number in the range 0 to 255. 8.6.1 planar insertion mode in planar insertion mode the destination pixel address outd specifies which pixel in each of the registers outpix0, outpix1 and outpix2 will be updated. vmu n writes to outpix n . this can be seen in figure 8-5 on page 29 and table 8-2 on page 47 . this mode is useful when transforming from one color space to another where the resulting color components should be stored in separate images. figure 8-5. planar pixel insertion vmu0_out coeff0_0 coeff0_1 coeff0_2 in((x+0)%11) in((x+4)%11) in((x+8)%11) offset0 or vmu0_out () + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in((y+0)%11) in((y+4)%11) in((y+8)%11) offset1 or vmu1_out () + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in((z+0)%11) in((z+4)%11) in((z+8)%11) offset2 or vmu2_out () + = outpix0 out0 out1 out2 out3 out4 out5 out6 out7 out8 out9 out10 out11 outpix1 outpix2 d = 0 d = 2 d = 1 d = 3 = vmu0 = vmu1 = vmu2
30 32015a?avr32?02/07 AT32AP7001 8.6.2 packed insertion mode in packed insertion mode the three output registers outpix0, outpix1 and outpix2 are divided into four pixel triplets as seen in figure 8-6 on page 30 and table 8-2 on page 47 . the destination pixel address is then the address of the pixel triplet. vmu n writes to pixel n of the pixel triplet.this mode is useful when transfo rming from one color space to another where the resulting color components sh ould be packed together. figure 8-6. packed pixel insertion. outpix0 out0 out1 out2 out3 out4 out5 out6 out7 out8 out9 out10 out11 d = 0 d = 1 d = 2 d = 3 outpix1 outpix2 = vmu0 = vmu1 = vmu2
31 32015a?avr32?02/07 AT32AP7001 8.7 user interface the pico uses the tcb interface to communicate with the cpu and the user can read from or write to the pico register file by using the pico load/store/move instructions which maps to generic coprocessor instructions. 8.7.1 register file the pico register file can be accessed from the cpu by using the picomv.x, picold.x, picost.x, picoldm and picostm instructions. table 8-1. pico register file cp reg # register name access cr0 input pixel register 2 inpix2 read/write cr1 input pixel register 1 inpix1 read/write cr2 input pixel register 0 inpix0 read/write cr3 output pixel register 2 outpix2 read only cr4 output pixel register 1 outpix1 read only cr5 output pixel register 0 outpix0 read only cr6 coefficient register a for vmu0 coeff0_a read/write cr7 coefficient register b for vmu0 coeff0_b read/write cr8 coefficient register a for vmu1 coeff1_a read/write cr9 coefficient register b for vmu1 coeff1_b read/write cr10 coefficient register a for vmu2 coeff2_a read/write cr11 coefficient register b for vmu2 coeff2_b read/write cr12 output from vmu0 vmu0_out read/write cr13 output from vmu1 vmu1_out read/write cr14 output from vmu2 vmu2_out read/write cr15 pico configuration register config read/write
32 32015a?avr32?02/07 AT32AP7001 8.7.1.1 input pixel register 0 register name: inpix0 access type: read/write ? in0: input pixel 0 input pixel number 0 to the input pixel selector unit. ? in1: input pixel 1 input pixel number 1 to the input pixel selector unit. ? in2: input pixel 2 input pixel number 2 to the input pixel selector unit. ? in3: input pixel 3 input pixel number 3 to the input pixel selector unit. 31 30 29 28 27 26 25 24 in0 23 22 21 20 19 18 17 16 in1 15 14 13 12 11 10 9 8 in2 76543210 in3
33 32015a?avr32?02/07 AT32AP7001 8.7.1.2 input pixel register 1 register name: inpix1 access type: read/write ? in0: input pixel 4 input pixel number 4 to the input pixel selector unit. ? in1: input pixel 5 input pixel number 5 to the input pixel selector unit. ? in2: input pixel 6 input pixel number 6 to the input pixel selector unit. ? in3: input pixel 7 input pixel number 7 to the input pixel selector unit. 31 30 29 28 27 26 25 24 in4 23 22 21 20 19 18 17 16 in5 15 14 13 12 11 10 9 8 in6 76543210 in7
34 32015a?avr32?02/07 AT32AP7001 8.7.1.3 input pixel register 2 register name: inpix2 access type: read/write ? in0: input pixel 8 input pixel number 8 to the input pixel selector unit. ? in1: input pixel 9 input pixel number 9 to the input pixel selector unit. ? in2: input pixel 10 input pixel number 10 to the input pixel selector unit. ? in3: input pixel 11 input pixel number 11 to the input pixel selector unit. 31 30 29 28 27 26 25 24 in8 23 22 21 20 19 18 17 16 in9 15 14 13 12 11 10 9 8 in10 76543210 in11
35 32015a?avr32?02/07 AT32AP7001 8.7.1.4 output pixel register 0 register name: outpix0 access type: read ? out0: output pixel 0 output pixel number 0 from the output pixel inserter unit. ? out1: output pixel 1 output pixel number 1 from the output pixel inserter unit. ? out2: output pixel 2 output pixel number 2 from the output pixel inserter unit. ? out3: output pixel 3 output pixel number 3 from the output pixel inserter unit. 31 30 29 28 27 26 25 24 out0 23 22 21 20 19 18 17 16 out1 15 14 13 12 11 10 9 8 out2 76543210 out3
36 32015a?avr32?02/07 AT32AP7001 8.7.1.5 output pixel register 1 register name: outpix1 access type: read ? out4: output pixel 4 output pixel number 4 from the output pixel inserter unit. ? out5: output pixel 5 output pixel number 5 from the output pixel inserter unit. ? out6: output pixel 6 output pixel number 6 from the output pixel inserter unit. ? out7: output pixel 7 output pixel number 7 from the output pixel inserter unit. 31 30 29 28 27 26 25 24 out4 23 22 21 20 19 18 17 16 out5 15 14 13 12 11 10 9 8 out6 76543210 out7
37 32015a?avr32?02/07 AT32AP7001 8.7.1.6 output pixel register 2 register name: outpix2 access type: read ? out8: output pixel 8 output pixel number 8 from the output pixel inserter unit. ? out9: output pixel 9 output pixel number 9 from the output pixel inserter unit. ? out10: output pixel 10 output pixel number 10 from the output pixel inserter unit. ? out11: output pixel 11 output pixel number 11 from the output pixel inserter unit. 31 30 29 28 27 26 25 24 out8 23 22 21 20 19 18 17 16 out9 15 14 13 12 11 10 9 8 out10 76543210 out11
38 32015a?avr32?02/07 AT32AP7001 8.7.1.7 coefficient register a for vmu0 register name: coeff0_a access type: read/write ? coeff0_0: coefficient 0 for vmu0 coefficient 0 input to vmu0. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff0_0 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff0_0 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? coeff0_1: coefficient 1 for vmu0 coefficient 1 input to vmu0. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff0_1 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff0_1 is sign- extended to 16-bits in or der to fill in the unused bits in th e lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff0_0 23 22 21 20 19 18 17 16 coeff0_0 15 14 13 12 11 10 9 8 ---- coeff0_1 76543210 coeff0_1 coeff0_0 2 coeff_frac_bits ? coeff0_1 2 coeff_frac_bits ?
39 32015a?avr32?02/07 AT32AP7001 8.7.1.8 coefficient register b for vmu0 register name: coeff0_b access type: read/write ? coeff0_2: coefficient 2 for vmu0 coefficient 2 input to vmu0. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff0_2 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff0_2 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? offset0: offset for vmu0 offset input to vmu0 in case of non-accumulating operations. a signed 12-bit fixed-point number where the number of frac- tional bits is given by the offset_fra c_bits field in the config register. t he actual fractional number is equal to , where the offset0 value is interpreted as a 2?s complement integer. when reading this reg- ister, offset0 is sign-extended to 16-bits in order to fill in the unused bits in the lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff0_2 23 22 21 20 19 18 17 16 coeff0_2 15 14 13 12 11 10 9 8 ---- offset0 76543210 offset0 coeff0_2 2 coeff_frac_bits ? offset0 2 offset_frac_bits ?
40 32015a?avr32?02/07 AT32AP7001 8.7.1.9 coefficient register a for vmu1 register name: coeff1_a access type: read/write ? coeff1_0: coefficient 0 for vmu1 coefficient 0 input to vmu1. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff1_0 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff1_0 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? coeff1_1: coefficient 1 for vmu1 coefficient 1 input to vmu0. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff1_1 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff1_1 is sign- extended to 16-bits in or der to fill in the unused bits in th e lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff1_0 23 22 21 20 19 18 17 16 coeff1_0 15 14 13 12 11 10 9 8 ---- coeff1_1 76543210 coeff1_1 coeff1_0 2 coeff_frac_bits ? coeff1_1 2 coeff_frac_bits ?
41 32015a?avr32?02/07 AT32AP7001 8.7.1.10 coefficient register b for vmu1 register name: coeff1_b access type: read/write ? coeff1_2: coefficient 2 for vmu1 coefficient 2 input to vmu1. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff1_2 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff1_2 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? offset1: offset for vmu1 offset input to vmu1 in case of non-accumulating operations. a signed 12-bit fixed-point number where the number of frac- tional bits is given by the offset_fra c_bits field in the config register. t he actual fractional number is equal to , where the offset1 value is interpreted as a 2?s complement integer. when reading this reg- ister, offset1 is sign-extended to 16-bits in order to fill in the unused bits in the lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff1_2 23 22 21 20 19 18 17 16 coeff1_2 15 14 13 12 11 10 9 8 ---- offset1 76543210 offset1 coeff1_2 2 coeff_frac_bits ? offset1 2 offset_frac_bits ?
42 32015a?avr32?02/07 AT32AP7001 8.7.1.11 coefficient register a for vmu2 register name: coeff2_a access type: read/write ? coeff2_0: coefficient 0 for vmu2 coefficient 0 input to vmu2. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff2_0 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff2_0 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? coeff2_1: coefficient 1 for vmu2 coefficient 1 input to vmu2. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff2_1 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff2_1 is sign- extended to 16-bits in or der to fill in the unused bits in th e lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff2_0 23 22 21 20 19 18 17 16 coeff2_0 15 14 13 12 11 10 9 8 ---- coeff2_1 76543210 coeff2_1 coeff2_0 2 coeff_frac_bits ? coeff2_1 2 coeff_frac_bits ?
43 32015a?avr32?02/07 AT32AP7001 8.7.1.12 coefficient register b for vmu2 register name: coeff2_b access type: read/write ? coeff2_2: coefficient 2 for vmu2 coefficient 2 input to vmu2. a signed 12-bit fixed-point number where the number of fractional bits is given by the coeff_frac_bits field in the config register. the actual fractional number is equal to , where the coeff2_2 value is interpreted as a 2?s compleme nt integer. when reading this register, coeff2_2 is sign- extended to 16-bits in or der to fill in the unused bits in th e upper halfword of this register. ? offset2: offset for vmu2 offset input to vmu2 in case of non-accumulating operations. a signed 12-bit fixed-point number where the number of frac- tional bits is given by the offset_fra c_bits field in the config register. t he actual fractional number is equal to , where the offset2 value is interpreted as a 2?s complement integer. when reading this reg- ister, offset2 is sign-extended to 16-bits in order to fill in the unused bits in the lower halfword of this register. 31 30 29 28 27 26 25 24 ---- coeff2_2 23 22 21 20 19 18 17 16 coeff2_2 15 14 13 12 11 10 9 8 ---- offset2 76543210 offset2 coeff2_2 2 coeff_frac_bits ? offset2 2 offset_frac_bits ?
44 32015a?avr32?02/07 AT32AP7001 8.7.1.13 vmu0 output register register name: vmu0_out access type: read/write ? vmu0_out: output from vmu0 this register is used for directly accessing the output from vmu0 or for setting the initial value of the accumulator for accu- mulating operations. the output from vmu0 is a signed 22-bit fixed-point number where the number of fractional bits are given by the coeff_frac_bits field in the config register. wh en reading this register the signed 22-bit value is sign- extended to 32-bits. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - vmu0_out 15 14 13 12 11 10 9 8 vmu0_out 76543210 vmu0_out
45 32015a?avr32?02/07 AT32AP7001 8.7.1.14 vmu1 output register register name: vmu1_out access type: read/write ? vmu1_out: output from vmu1 this register is used for directly accessing the output from vmu1 or for setting the initial value of the accumulator for accu- mulating operations. the output from vmu1 is a signed 22-bit fixed-point number where the number of fractional bits are given by the coeff_frac_bits field in the config register. wh en reading this register the signed 22-bit value is sign- extended to 32-bits. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - vmu1_out 15 14 13 12 11 10 9 8 vmu1_out 76543210 vmu1_out
46 32015a?avr32?02/07 AT32AP7001 8.7.1.15 vmu2 output register register name: vmu2_out access type: read/write ? vmu2_out: output from vmu2 this register is used for directly accessing the output from vmu2 or for setting the initial value of the accumulator for accu- mulating operations. the output from vmu2 is a signed 22-bit fixed-point number where the number of fractional bits are given by the coeff_frac_bits field in the config register. wh en reading this register the signed 22-bit value is sign- extended to 32-bits. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 - - vmu2_out 15 14 13 12 11 10 9 8 vmu2_out 76543210 vmu2_out
47 32015a?avr32?02/07 AT32AP7001 8.7.1.16 pico configuration register register name: config access type: read/write ? oim: output insertion mode the oim bit specifies the semantics of the outd output pixel address parameter to the pico(s)v(mul/mac) instructions. the oim together with the output pixel address parameter specify which of the 12 output bytes (out n ) of the outpix n regis- ters will be updated with th e results from the vmus. table 8-2 on page 47 describes the different output insertion modes. see section 8.6 ?output pixel inserter? on page 29 for a description of the output pixel inserter. ? ism: input selection mode the ism field specifies the semantics of the input pixel address parameters inx, iny and inz to the pico(s)v(mul/mac) instructions. together with the three input pixel addresses the ism field specifies to the input pixel selector which of th e input pixels (in n ) that should be selected as inputs to the vmus. table 8-3 on page 48 describes the 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -----oim ism 76543210 offset_frac_bits coeff_frac_bits table 8-2. output insertion modes oim mode description 0 packed insertion mode {outpix0, outpix1, outpix2} is treated as one large register containing 4 sequential 24- bit pixel triplets. the dst_adr field specifies wh ich of the sequential triplets will be updated. out(d*3 + 0) scaled and saturated output from vmu0 out(d*3 + 1) scaled and saturated output from vmu1 out(d*3 + 2) scaled and saturated output from vmu2 1 planar insertion mode each of the outpix n registers will get one of the resulting pixels. the triplet address specifies what byte in each of the outpix n registers the results will be written to. out(d + 0) scaled and saturated output from vmu0 out(d+ 4) scaled and saturated output from vmu1 out(d + 8) scaled and saturated output from vmu2
48 32015a?avr32?02/07 AT32AP7001 different input selection modes. see section 8.5 ?input pixel selector? on page 27 for a description of the input pixel selector. ? offset_frac_bits: offset fractional bits specifies the number of fractional bits in the fixed-point offsets input to each vmu. must be in the range from 0 to coeff_frac_bits. other values gives undefined resu lts.this value is used for scaling the offset n values before being input to vmu n so that the offset will have the same fixed-point format as the outputs from the multiplication stages before performing the vector addition in the vmu. ? coeff_frac_bits: coefficient fractional bits specifies the number of fractional bits in the fixed-point coefficients input to each vmu. must be in the range from 0 to 11, since at least one bit of the coefficient must be us ed for the sign. other values gives undefined results. coeff_frac_bits is used in the output pixel inserter to sc ale the fixed-point results from the vmus back to unsigned 8- bit integers. table 8-3. input selection modes ism mode 0 0 transformation mode vmu0, vmu1 and vmu2 get the same pixel inputs. these three pixels can be freely selected from the inpix n registers. 0 1 horizontal filter mode pixel triplets are selected for input to each of the vmus by addressing horizontal pixel triplets from the inpix n registers. 1 0 vertical filter mode pixel triplets are selected for input to each of the vmus by addressing vertical pixel triplets from the inpix n registers. 1 1 reserved n.a
49 32015a?avr32?02/07 AT32AP7001 8.8 pico instructions 8.8.1 pico instructions nomenclature 8.8.1.1 registers and operands r {d, s, ?} the uppercase ? r ? denotes a 32-bit (word) register. r d the lowercase ? d ? denotes the destination register number. r s the lowercase ? s ? denotes the source register number. r b the lowercase ? b ? denotes the base register number for indexed addressing modes. r i the lowercase ? i ? denotes the index register number for indexed addressing modes. r p the lowercase ? p ? denotes the pointer register number. in {x, y, z} the uppercase ? in ? denotes a pixel in the inpix n registers. in x the lowercase ? x ? denotes the first input pixel number for the pico operation instructions. in y the lowercase ? y ? denotes the second input pixel number for the pico operation instructions. in z the lowercase ? z ? denotes the third input pixel number for the pico operation instructions. out d the uppercase ? out ? denotes a pixel in the outpix n registers. out d the lowercase ? d ? denotes the destination pixel number for the pico operation instructions. pr pico register. see section 8.7.1 ?register file? on page 31 for a complete list of registers. prhi:prlo pico register pair. only register pairs corresponding to valid coprocessor double registers are valid. e.g. inpix1:inpix2 (cr1:cr0). the low part must correspond to an even coprocessor register number n and the high part must then correspond to coprocessor register n+1 . see table 8-1 on page 31 for a mapping between pico register names and coprocessor register numbers. pc program counter, equal to r15 lr link register, equal to r14 sp stack pointer, equal to r13 picoreglist register list used in the picoldm and picostm instructions. see instruct ion description for which register combinations are allowed in the register list. disp displacement sa shift amount [i] denotes bit i in a immediate value. example: imm6[4] denotes bit 4 in an 6-bit immediate value. [i:j] denotes bit i to j in an immediate value. some instructions access or use doubleword operands. these operands must be placed in two consecutive register addresses where the first register must be an even register . the even register contains the least significant part and the odd register contains the most significant part. this ordering is reversed in comparison with how data is organized in memory (where the most significant part would receive the lowest address) and is intentional.
50 32015a?avr32?02/07 AT32AP7001 the programmer is responsible for placing these operands in properly aligned register pairs. this is also specified in the "operands" section in the detailed de scription of each instruct ion. failure to do so will result in an undefined behavior. 8.8.1.2 operations asr(x, n) se(x, bits(x) + n) >> n satsu(x, n) signed to unsigned saturation ( x is treated as a signed value ): if (x > (2 n -1)) then (2 n-1 -1); elseif ( x < 0 ) then 0; else x; se(x, n) sign extend x to an n-bit value 8.8.1.3 data type extensions .d double (64-bit) operation. .w word (32-bit) operation.
51 32015a?avr32?02/07 AT32AP7001 8.8.2 pico instruction summary table 8-4. pico instruct ion summary mnemonics operands / syntax description operation picosvmac e outd, inx, iny, inz pico single vector multiplication and accumulation. see pico instruction set reference picosvmul e outd, inx, iny, inz pico single vector multiplication see pico instruction set reference picovmac e outd, inx, iny, inz pico vector multiplications and accumulations. see pico instruction set reference picovmul e outd, inx, iny, inz pico vector mult iplications. see pico instruction set reference picold.d e prhi:prlo, rp[disp] load pico register pair prhi:prlo *(rp+ze(disp8<<2)) e prhi:prlo, --rp load pico register pair with pre-decrement prhi:prlo *(--rp) e prhi:prlo, rb[ri< 52 32015a?avr32?02/07 AT32AP7001 picosvmac ? pico single vector multiplication and accumulation description performs three vector multiplications where the input pixels taken from the inpix n registers depends on the input selection mode and the input pixel addresses given in the instruction. the values in the vmu n _out registers are then accumulated with the new results from the vector mult iplications. the results from each vector multiplication unit (vmu) are then added together for one of the outputs to the output pixels inserter to form the result of a single vector multiplication of two 9-ele - ment vectors. the results from the vmus are then scaled and saturated to unsigned 8-bit values before being inserted into the outpix n registers. which pixels to update in the outpix n registers depend upon the output insertion mode and the output pixel address given in the instruction. operation: i. if ( input selection mode == horizontal filter mode ) then else if ( input selection mode == vertical filter mode ) then else if ( input selection mode == transformation mode ) then if ( output insertion mode == packed insertion mode ) then out(d*3 + 0) satsu(asr(vmu0_out + vmu1_out + vmu2_out, coeff_frac_bits) , 8); out(d*3 + 1) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d*3 + 2) satsu(asr(vmu2_out, coeff_frac_bits), 8); else if ( output insertion mode == planar insertion mode ) then out(d + 0) satsu(asr(vmu0_out + vmu1_out+ vmu2_out, coeff_frac_bits), 8); out(d + 4) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d + 8) satsu(asr(vmu2_out, coeff_frac_bits), 8); vmu0_out coeff0_0 coeff0_1 coeff0_2 in(x+0) in(x+1) in(x+2) vmu0_out + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in(y+0) in(y+1) in(y+2) vmu1_out + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in(z+0) in(z+1) in(z+2) vmu2_out + = vmu0_out coeff0_0 coeff0_1 coeff0_2 in((x+0)%11) in((x+4)%11) in((x+8)%11) vmu0_out + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in((y+0)%11) in((y+4)%11) in((y+8)%11) vmu1_out + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in((z+0)%11) in((z+4)%11) in((z+8)%11) vmu2_out + = vmu0_out vmu1_out vmu2_out coeff0_0 coeff0_1 coeff0_2 coeff1_0 coeff1_1 coeff1_2 coeff2_0 coeff2_1 coeff2_2 inx iny inz vmu0_out vmu1_out vmu2_out + =
53 32015a?avr32?02/07 AT32AP7001 syntax: i. picosvmac outd, inx, iny, inz operands: i. d {0, 1, 2, 3} x, y, z {0, 1, ..., 11} opcode: example: /* inner loop of a 16-tap symmetric fir filter with coefficients {c0, c1, c2, c3, c4, c5 , c6, c7, c7, ..., c0} set to filter the pixels pointed to by r12 storing the result to the memory poi nted to by r11. the coeffici ents in the pico are already set to the following values: coeff0_0 = c0, coeff0_1 = c1, coeff0_2 = c2, coeff1_0 = c3, coeff1_1 = c4, coeff1_2 = c5, coeff2_0 = c6, coeff2_1 = c7, coeff 2_2 = 0, offset0 = 0.5 (for rounding the result), offset1 = 0, offset2 = 0. the input selection mode is set to horizontal filter mode while the output insertion mode is set to planar insertion mode. the input image pointer might be unaligned, hence the use of ld.w instead of picold.w. */ ... ld.w r1, r12[0] /* r1 = *((int *)src) */ ld.w r0, r12[4] /* r0 = *(((int *)src) + 1) */ ld.w r2, r12[8] /* r2 = *(((int *)src) + 2) */ ld.w r3, r12[12] /* r3 = *(((int *)src) + 3) */ picomv.d inpix1:inpix2, r0 /* inpix1={src[0],src[1],sr c[2],src[3]}, inpix2={src[4],src[5],src[6],src[7]}*/ swap.b r2 /* r2 = {src[11],src[10],src[9],src[8]}*/ swap.b r3 /* r3 = {src[15],src[14],src[13],src[12]}*/ picosvmul out3, in4, in7, in10 /* vmu0_o ut = c0*src[0]+c1*src[1]+c2*src[2] + 0.5 vmu1_out = c3*src[3]+c4*src[4]+c5*src[5] vmu2_out = c6*src[6]+c7*src[7] */ picomv.d inpix1:inpix2, r2 /* inpix1 ={src[15],src[14], src[13],src[12]}, inpix2 ={src[11],src[ 10],src[9],src[8]} */ picosvmac out3, in4, in7, in10 /* vmu0_o ut += c0*src[15]+c1*src[14]+c2*src[13] vmu1_out += c3*src[12]+c4*src[11]+c5*src[10] vmu2_out += c6*src[9]+c7*src[8] out3 = satscaled(vmu0_out+vmu1_out+vmu2_out)*/ sub r12, -1 /* src++ */ picomv.w r4, outpix0 /* r4 = { out0, out1, out2, out3 } st.b r11++, r4 /* *dst = out3 */ ... 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111000011010011 out d[1] 1514131211109876543210 pico cp# out d[0] inx iny inz
54 32015a?avr32?02/07 AT32AP7001 picosvmul ? pico single vector multiplication description performs three vector multiplications where the input pixels taken from the inpix n registers depends on the input selection mode and the input pixel addresses given in the instruction. the results from each vector multiplication unit (vmu) are then added together for one of the outputs to the output pixels inserter to form the result of a single vector multiplication of two 9-element vectors. the results from the vmus are then scaled and saturated to unsigned 8-bit values before being inserted into the outpix n registers. which pixels to update in the outpix n registers depend upon the output insertion mode and the output pixel address given in the instruction. operation: i. offset_scale = coeff_fr ac_bits - offset_frac_bits if ( input selection mode == horizontal filter mode ) then else if ( input selection mode == vertical filter mode ) then else if ( input selection mode == transformation mode ) then if ( output insertion mode == packed insertion mode ) then out(d*3 + 0) satsu(asr(vmu0_out + vmu1_out + vmu2_out, coeff_frac_bits), 8); out(d*3 + 1) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d*3 + 2) satsu(asr(vmu2_out, coeff_frac_bits), 8); else if ( output insertion mode == planar insertion mode ) then out(d + 0) satsu(asr(vmu0_out + vmu1_out+ vmu2_out, coeff_frac_bits), 8); out(d + 4) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d + 8) satsu(asr(vmu2_out, coeff_frac_bits), 8); vmu0_out coeff0_0 coeff0_1 coeff0_2 in(x+0) in(x+1) in(x+2) offset0 << offset_scale + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in(y+0) in(y+1) in(y+2) offset1 << offset_scale + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in(z+0) in(z+1) in(z+2) offset2 << offset_scale + = vmu0_out coeff0_0 coeff0_1 coeff0_2 in((x+0)%11) in((x+4)%11) in((x+8)%11) offset0 << offset_scale + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in((y+0)%11) in((y+4)%11) in((y+8)%11) offset1 << offset_scale + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in((z+0)%11) in((z+4)%11) in((z+8)%11) offset2 << offset_scale + = vmu0_out vmu1_out vmu2_out coeff0_0 coeff0_1 coeff0_2 coeff1_0 coeff1_1 coeff1_2 coeff2_0 coeff2_1 coeff2_2 inx iny inz offset0 << offset_scale offset1 << offset_scale offse20 << offset_scale + =
55 32015a?avr32?02/07 AT32AP7001 syntax: i. picosvmul outd, inx, iny, inz operands: i. d {0, 1, 2, 3} x, y, z {0, 1, ... , 11} opcode: example: /* excerpt from inner loop of bilinear interpolation filter op erating on image component stor ed in an array pointed to by r12. the width of the image is stored in r11 while the result ing filtered image is pointed to by r10. the coefficients of the filter: a, b, c, d are already set before this code is executed. coeff0 _0 = a, coeff0_1 = b, coeff0_2 = 0, coeff1_0 = c, coeff1_1 = d, coeff1_2 = 0, coeff2_0 = 0, coeff2_1 = 0, coeff2_2 = 0, offset0 = 0.5 (for rounding the result), offset1 = 0, offset2 = 0. the input selection mode is set to horizontal filter mode while the output insertion mode is set to planar insertion mode. the input image pointer might be unaligned, hence the use of ld.w instead of picold.w, while the output image pointer is word aligned. four output pixels are computed in th is example which show an example of a bilinear inte rpolation filter found in the motion compensation used in the h.264 video standard. */ ... ld.w r1, r12[0] /* r1 = *((int *)src) */ ld.w r0, r12[r11] /* r0 = *((int *)(src + width)) */ sub r12, -2 /* src+=2 */ ld.w r3, r12[0] /* r3 = *((int *)src) */ ld.w r2, r12[r11] /* r2 = *((int *)(src + width)) */ picomv.d inpix1:inpix2, r0 /* inpix1 = r1, inpix2 = r0 */ picosvmul out0, in4, in8, in0 /* out0 = a*src[j][i+0] + b*src[j][i+1] c*src[j+1][i] + d*src[j+1][i+1] */ picosvmul out1, in5, in9, in0 /* out1 = a*src[j][i+1 ] + b*src[j][i+2] c*src[j+1] [i+1] + d*src[j+1][i+2] */ picomv.d inpix1:inpix2, r2 /* inpix1 = r3, inpix2 = r2 */ picosvmul out2, in4, in8, in0 /* out2 = a*src[j][i+2 ] + b*src[j][i+3] c*src[j+1] [i+2] + d*src[j+1][i+3] */ picosvmul out3, in5, in9, in0 /* out3 = a*src[j][i+3 ] + b*src[j][i+4] c*src[j+1] [i+3] + d*src[j+1][i+4] */ sub r12, -2 /* src+=2 */ picost.w r10++, outpix0 /* *((int *)src) = { out0, out1, out2, out3 } */ ... 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111000011010010 out d[1] 1514131211109876543210 pico cp# out d[0] inx iny inz
56 32015a?avr32?02/07 AT32AP7001 picovmac ? pico vector mu ltiplication and accumulation description performs three vector multiplications where the input pixels taken from the inpix n registers depends on the input selection mode and the input pixel addresses given in the instruction. the values in the vmu n _out registers are then accumulated with the new results from the vector multiplications. the results from the vmus are then scaled and saturated to unsigned 8-bit values before being inserted into the outpix n registers. which pixels to update in the outpix n registers depend upon the output insertion mode and the output pixel address given in the instruction. operation: i. if ( input selection mode == horizontal filter mode ) then else if ( input selection mode == vertical filter mode ) then else if ( input selection mode == transformation mode ) then if ( output insertion mode == packed insertion mode ) then out(d*3 + 0) satsu(asr(vmu0_out, coeff_frac_bits), 8); out(d*3 + 1) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d*3 + 2) satsu(asr(vmu2_out, coeff_frac_bits), 8); else if ( output insertion mode == planar insertion mode ) then out(d + 0) satsu(asr(vmu0_out, coeff_frac_bits), 8); out(d + 4) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d + 8) satsu(asr(vmu2_out, coeff_frac_bits), 8); vmu0_out coeff0_0 coeff0_1 coeff0_2 in(x+0) in(x+1) in(x+2) vmu0_out + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in(y+0) in(y+1) in(y+2) vmu1_out + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in(z+0) in(z+1) in(z+2) vmu2_out + = vmu0_out coeff0_0 coeff0_1 coeff0_2 in((x+0)%11) in((x+4)%11) in((x+8)%11) vmu0_out + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in((y+0)%11) in((y+4)%11) in((y+8)%11) vmu1_out + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in((z+0)%11) in((z+4)%11) in((z+8)%11) vmu2_out + = vmu0_out vmu1_out vmu2_out coeff0_0 coeff0_1 coeff0_2 coeff1_0 coeff1_1 coeff1_2 coeff2_0 coeff2_1 coeff2_2 inx iny inz vmu0_out vmu1_out vmu2_out + =
57 32015a?avr32?02/07 AT32AP7001 syntax: i. picovmac outd, inx, iny, inz operands: i. d {0, 1, 2, 3} x, y, z {0, 1, ... , 11} opcode: example: /* inner loop of a 6-tap symmetric fir filter with coefficients {c0, c1, c2, c2, c1, c0 } set to filter in the vertical direction of the image pointed to by r12 with the width of the image stored in r11 and the destinat ion image stored in r10. the coefficients in the pico are already set to the following values: coeff0_0 = c0, coeff0_1 = c1, coeff0_2 = c2, coeff1_0 = c0, coeff1_1 = c1, coeff1_2 = c2, coeff2_0 = c0, coeff2_1 = c1, coeff2_2 = c2, offset0 = offset1 = offset2 = 0.5 (for rounding the result). the input selection mode is set to vertical filter mode wh ile the output insertion mode is set to packed insertion mode. the input image is assumed to be word aligned. */ ... picold.w inpix0, r12[0] /* inpix0 = {src[0][0], src[0][1], src[0][2], src[0][3] }*/ picold.w inpix1, r12[r11] /* inpix1 = {src[1][0], src[1][1], src[1][2], src[1][3] }*/ picold.w inpix2, r12[r11 << 1] /* inpix2 = {src[2][0], src[2][1], src[2][2], src[2][3] }*/ add r9, r12, r11 /* r9 = src + width */ picovmul out0, in0, in1, in2 /* vmu0_out = c 0*src[0][0]+c1*src[1][0]+c2*src[2][0] + 0.5 vmu1_out = c0*src[0][1]+c1* src[1][1]+c2*src[2][1] + 0.5 vmu2_out = c0*src[0][2]+c1*sr c[1][2]+c2*src[2][2] + 0.5*/ picold.w inpix2, r9[r11 << 1] /* inpix2 = {src[3][0], src[3][1], src[3][2], src[3][3] }*/ picold.w inpix1, r12[r11 << 2] /* inpix1 = {src[4][0], src[4][1], src[4][2], src[4][3] }*/ picold.w inpix0, r9[r11 << 2] /* inpix0 = {src[5][0], src[5][1], src[5][2], src[5][3] }*/ picovmac out0, in0, in1, in2 /* vmu0_out += c0*src[5][0]+c1*src[4][0]+c2*src[3][0] vmu1_out += c0*src[5][1]+c1*src[4][1]+c2*src[3][1] vmu2_out += c0*src[5][2]+c1*src[4][2]+c2*src[3][2] out0 = satscale(vmu0_out), out1 = satscale(vmu1_out), out2 = satscale(vmu2_out) */ .... 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111000011010001 out d[1] 1514131211109876543210 pico cp# out d[0] inx iny inz
58 32015a?avr32?02/07 AT32AP7001 picovmul ? pico vector multiplication description performs three vector multiplications where the input pixels taken from the inpix n registers depends on the input selection mode and the input pixel addresses given in the instruction. the results from the vmus are then scaled and saturated to unsigned 8-bit values before being inserted into the outpix n registers. which pixels to update in the outpix n registers depend upon the output insertion mode and the output pixel address given in the instruction. operation: i. offset_scale = coeff_fr ac_bits - offset_frac_bits if ( input selection mode == horizontal filter mode ) then else if ( input selection mode == vertical filter mode ) then else if ( input selection mode == transformation mode ) then if ( output insertion mode == packed insertion mode ) then out(d*3 + 0) satsu(asr(vmu0_out, coeff_frac_bits), 8); out(d*3 + 1) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d*3 + 2) satsu(asr(vmu2_out, coeff_frac_bits), 8); else if ( output insertion mode == planar insertion mode ) then out(d + 0) satsu(asr(vmu0_out, coeff_frac_bits), 8); out(d + 4) satsu(asr(vmu1_out, coeff_frac_bits), 8); out(d + 8) satsu(asr(vmu2_out, coeff_frac_bits), 8); vmu0_out coeff0_0 coeff0_1 coeff0_2 in(x+0) in(x+1) in(x+2) offset0 << offset_scale + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in(y+0) in(y+1) in(y+2) offset1 << offset_scale + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in(z+0) in(z+1) in(z+2) offset2 << offset_scale + = vmu0_out coeff0_0 coeff0_1 coeff0_2 in((x+0)%11) in((x+4)%11) in((x+8)%11) offset0 << offset_scale + = vmu1_out coeff1_0 coeff1_1 coeff1_2 in((y+0)%11) in((y+4)%11) in((y+8)%11) offset1 << offset_scale + = vmu2_out coeff2_0 coeff2_1 coeff2_2 in((z+0)%11) in((z+4)%11) in((z+8)%11) offset2 << offset_scale + = vmu0_out vmu1_out vmu2_out coeff0_0 coeff0_1 coeff0_2 coeff1_0 coeff1_1 coeff1_2 coeff2_0 coeff2_1 coeff2_2 inx iny inz offset0 << offset_scale offset1 << offset_scale offse20 << offset_scale + =
59 32015a?avr32?02/07 AT32AP7001 syntax: i. picovmul outd, inx, iny, inz operands: i. d {0, 1, 2, 3} x, y, z {0, 1, ... , 11} opcode: example: /* excerpt from inner loop of ycrcb 4:2:2 planar format to rgb packed format image colo r conversion. the coefficients of the transform is already set before this code is executed. in transforms like this, the inputs y, cr and cb are often offsetted with a given amount. this offset can be factored out and included in the offsets like this: 1.164*(y - 16) = 1.164*y - 18.625. the pointer to the y component is in r12, the pointer to the cr component in r11 and the pointer to the cb component in r10. the pointer to the rgb output image is in r9. the input selection mode is set to transform mode while the output insertion mode is set to packed insertion mode. it is assumed that all the input and output pointers are word aligned. four rgb triplets are com puted in this example. */ ... picold.w inpix0, r12++ /* inpix0= { y[0], y[1], y[ 2], y[3] }*/ picold.w inpix1, r11++ /* inpix1= { cr[0], cr[1], cr[2], cr[3] }*/ picold.w inpix2, r10++ /* inpix2= { cb[0], cb[1], cb[2], cb[3] }*/ picovmul out0, in0, in4, in8 /* out0 = r[0], out1 = g[0], out2 = b[0] */ picovmul out1, in1, in4, in8 /* out3 = r[1], out4 = g[1], out5 = b[1] */ picovmul out2, in2, in5, in9 /* out6 = r[2], out7 = g[2], out8 = b[2] */ picovmul out3, in3, in5, in9 /* out9 = r[3], out10 = g[3], out11 = b[3] */ picostm r9, outpix2, outpix1, outpix0/* rgb = {r[0],g[ 0],b[0],r[1],g[1],b[1],r[2],g[2],b[2],r[3],g[3],b[3]} */ ... 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111000011010000 out d[1] 1514131211109876543210 pico cp# out d[0] inx iny inz
60 32015a?avr32?02/07 AT32AP7001 picold.{d,w} ? load pico register(s) description reads the memory location specified into the given coprocessor register(s). operation: i. prhi:prlo *(rp + (ze(disp8) << 2)); ii. rp rp-8; prhi:prlo *(rp); iii. prhi:prlo *(rb + (ri << sa2)); iv. pr *(rp + (ze(disp8) << 2)); v. r p rp-4; pr *(rp); vi. pr *(rb + (ri << sa2)); syntax: i. picold.d prhi:prlo, rp[disp] ii. picold.d prhi:prlo, --rp iii. picold.d prhi:prlo, rb[ri< 61 32015a?avr32?02/07 AT32AP7001 iii. iv. v. vi. example: picold.d coeff0_b:coeff0_a, r12[4] 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 1 prlo[3:1] 0 0 1 shamt ri 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111010011010 rp 1514131211109876543210 pico cp# 0 pr disp8 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 0 pr 0 1 0 0 0 0 0 0 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 1 pr 0 0 shamt ri
62 32015a?avr32?02/07 AT32AP7001 picoldm ? load multiple pico registers description reads the memory locations specified into the given pico regist ers. the pointer register can optionally be updated after the operation. operation: i. ii. iii. loadaddress rp; if ( picoreglist contains config ) config *(loadaddress++); if ( picoreglist contains vmu2_out ) vmu2_out *(loadaddress++); if ( picoreglist contains vmu1_out ) vmu1_out *(loadaddress++); if ( picoreglist contains vmu0_out ) vmu0_out *(loadaddress++); if ( picoreglist contains coeff2_b) coeff2_b *(loadaddress++); if ( picoreglist contains coeff2_a) coeff2_a *(loadaddress++); if ( picoreglist contains coeff1_b) coeff1_b *(loadaddress++); if ( picoreglist contains coeff1_a) coeff1_a *(loadaddress++); if ( picoreglist contains coeff0_b) coeff0_b *(loadaddress++); if ( picoreglist contains coeff0_a) coeff0_a *(loadaddress++); if ( picoreglist contains outpix0) loadaddress++; if ( picoreglist contains outpix1) loadaddress++; if ( picoreglist contains outpix2) loadaddress++; if ( picoreglist contains inpix0) inpix0 *(loadaddress++); if ( picoreglist contains inpix1) inpix1 *(loadaddress++); if ( picoreglist contains inpix2) inpix2 *(loadaddress++); if opcode[++] == 1 then rp loadaddress; syntax: i. picoldm rp{++}, picoreglist ii. picoldm rp{++}, picoreglist iii. picoldm rp{++}, picoreglist operands: i. picoreglist { {inpix1, inpix2}, {out pix2, inpix0}, {outpix0, ou tpix1}, {coeff0_b, coeff0_a}, {coeff1_b, coeff1_a}, {coeff2_b, coeff2_a}, {vmu1_out, vmu0_out},
63 32015a?avr32?02/07 AT32AP7001 {config, vmu2_out} } ii. picoreglist { inpix0, inpix1, inpix2, outpix0, outpix1, outpix2, coeff0_a, coeff0_b } iii. picoreglist { coeff1_a, coeff1_b, coeff2_a,coeff2_b, vmu0_out,vmu1_out, vmu2_out, config, } i-iii. p {0, 1, ?, 15} opcode i. ii. iii. example: i. picoldm r7++, coeff0_a, coeff0_b, co eff1_a, coeff1_b, coeff2_a, coeff2_b ii. picoldm r0, inpix0, inpix1, inpix2 iii. picoldm r12, vmu0_out, vmu1_out, vmu2_out 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 1 0 0 config vmu2_out vmu1_out vmu0_out coeff2_b coeff2_a coeff1_b coeff1_a coeff0_b coeff0_a outpix0 outpix1 outpix2 inpix0 inpix1 inpix2 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 0 0 0 coeff0_b coeff0_a outpix0 outpi x1 outpix2 inpix0 inpix1 inpix2 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 0 0 1 config vmu2_out vmu1_out vmu0_out co eff2_b coeff2_a co eff1_b coeff1_a
64 32015a?avr32?02/07 AT32AP7001 picomv.{d,w} ? move between pico register(s) and register file description move the specified pico register(s) to register(s) in the register file or move register(s) in th e register file to pico regis- ter(s). operation: i. prhi:prlo (rs+1:rs); ii. pr rs; iii. (rd+1:rd) prhi:prlo; iv. rd pr; syntax: i. picomv.d prhi:prlo, rs ii. picomv.w pr, rs iii. picomv.d rd, prhi:prlo iv. picomv.w rd, pr operands: i, ii. prhi:prlo { inpix1:inpix2, outpix2:inpix0, outpix0:outpix1, coeff0_b:coeff0_a, coeff1_b:coeff1_a, coeff2_b:coeff2_a, vmu1_out:vmu0_out, config:vmu2_out } ii, iv. pr { inpix0, inpix1, inpix2, outpix0, outpix1, outpix2, coeff0_a, coeff0_b, coeff1_a, coeff1_b, coeff2_a, coeff2_b, vmu0 _out, vmu1_out, vmu2_out, config} i. s {0, 2, 4, ?, 14} iii. d {0, 2, 4, ?, 14} ii. s {0, 1, ?, 15} iv. d {0, 1, ?, 15} opcode i. ii. 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rs 0 1514131211109876543210 pico cp# 0 prlo[3:1] 000110000 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rs 1514131211109876543210 pico cp# 0 pr 00100000
65 32015a?avr32?02/07 AT32AP7001 iii. iv. example: picomv.d r2, outpix0:outpix1 picomv.w config, lr 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rd 0 1514131211109876543210 pico cp# 0 prlo[3:1] 000010000 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rd 1514131211109876543210 pico cp# 0 pr 00000000
66 32015a?avr32?02/07 AT32AP7001 picost.{d,w} ? store pico register(s) description stores the pico register value(s) to the memory location specified by the addressing mode. operation: i. *(rp + (ze(disp8) << 2)) prhi:prlo; ii. *(rp) prhi:prlo; rp rp+8; iii. *(rb + (ri << sa2)) prhi:prlo; iv. *(rp + (ze(disp8) << 2)) pr; v. * ( r p ) pr; rp rp-4; vi. *(rb + (ri << sa2)) pr; syntax: i. picost.d rp[disp], prhi:prlo ii. picost.d rp++, prhi:prlo iii. picost.d rb[ri< 67 32015a?avr32?02/07 AT32AP7001 iii. iv. v. vi. example: picost.w r10++, outpix0 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 1 prlo[3:1] 0 1 1 shamt ri 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111010111010 rp 1514131211109876543210 pico cp# 0 pr disp8 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 0 pr 0 1 1 0 0 0 0 0 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 111011111010 rp 1514131211109876543210 pico cp# 1 pr 1 0 shamt ri
68 32015a?avr32?02/07 AT32AP7001 picostm ? store multiple pico registers description writes the pico registers specified in the regi ster list into the spec ified memory locations. operation: i. ii. iii. if opcode[--] == 1 then rp rp - 4*registersinlist; storeaddress rp; if ( picoreglist contains config ) *(storeaddress++) config; if ( picoreglist contains vmu2_out ) *(storeaddress++) vmu2_out; if ( picoreglist contains vmu1_out ) *(storeaddress++) vmu1_out; if ( picoreglist contains vmu0_out ) *(storeaddress++) vmu0_out; if ( picoreglist contains coeff2_b) *(storeaddress++) coeff2_b; if ( picoreglist contains coeff2_a) *(storeaddress++) coeff2_a; if ( picoreglist contains coeff1_b) *(storeaddress++) coeff1_b; if ( picoreglist contains coeff1_a) *(storeaddress++) coeff1_a; if ( picoreglist contains coeff0_b) *(storeaddress++) coeff0_b; if ( picoreglist contains coeff0_a) *(storeaddress++) coeff0_a; if ( picoreglist contains outpix0) *(storeaddress++) outpix0; if ( picoreglist contains outpix1) *(storeaddress++) outpix1; if ( picoreglist contains outpix2) *(storeaddress++) outpix2; if ( picoreglist contains inpix0) *(storeaddress++) inpix0 ; if ( picoreglist contains inpix1) *(storeaddress++) inpix1 ; if ( picoreglist contains inpix2) *(storeaddress++) inpix2 ; syntax: i. picostm {--}rp, picoreglist ii. picostm {--}rp, picoreglist iii. picostm {--}rp, picoreglist operands: i. picoreglist { {inpix1, inpix2}, {out pix2, inpix0}, {outpix0, ou tpix1}, {coeff0_b, coeff0_a}, {coeff1_b, coeff1_a}, {coeff2_b, coeff2_a}, {vmu1_out, vmu0_out},
69 32015a?avr32?02/07 AT32AP7001 {config, vmu2_out} } ii. picoreglist { inpix0, inpix1, inpix2, outpix0, outpix1, outpix2, coeff0_a, coeff0_b } iii. picoreglist { coeff1_a, coeff1_b, coeff2_a,coeff2_b, vmu0_out,vmu1_out, vmu2_out, config, } i-iii. p {0, 1, ?, 15} opcode i. ii. iii. example: i. picostm --r7, coeff0_a, coeff0_b, coeff1_a, coeff1_b, coeff2_a, coeff2_b ii. picostm r2, outpix0, outpix1, outpix2 iii. picostm r11, vmu0_out, vmu1_out, vmu2_out 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 1 0 1 config vmu2_out vmu1_out vmu0_out coeff2_b coeff2_a coeff1_b coeff1_a coeff0_b coeff0_a outpix0 outpix1 outpix2 inpix0 inpix1 inpix2 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 0 1 0 coeff0_b coeff0_a outpix0 outpi x1 outpix2 inpix0 inpix1 inpix2 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 11101101 1 0 1 0 rp 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 pico cp# w 0 0 1 1 config vmu2_out vmu1_out vmu0_out co eff2_b coeff2_a co eff1_b coeff1_a
70 32015a?avr32?02/07 AT32AP7001 8.9 data hazards data hazards are caused by data dependencies between instructions which are in different stages of the pipeline and reads/writes registers which are common to several pipeline stages. because of the 3-stage pipeline employed in the pico data hazards might exist between instruc- tions. data hazards are handled by hardware interlocks which can stall a new read command from or write command to the pico register file. table 8-5. data hazards instruction next instruction condition stall cycles picovmul picovmac picosvmul picosvmac picomv.x pr,... picold.x picoldm write-after-read (war) or write-after-write (waw) hazard will occur if writing coeff n _a/b, vmu n _out or config since these ar e accessed when the pico command is in pipeline stage 2 and pipeline stage 3. 1 writes to inpix n registers produces no hazard since they are only accessed in pipeline stage 1. 0 picomv.x rd,... picost.x picostm read-after-write hazard (r aw) will occur if reading the pico register file while a command is in the pipeline. 2
71 32015a?avr32?02/07 AT32AP7001 9. memories 9.1 embedded memories ? 32 kbyte sram ? implemented as two 16kbyte blocks ? single cycle access at full bus speed 9.2 physical memory map the system bus is implemented as an hsb bus matrix. all system bus addresses are fixed, and they are never remapped in any way, not even in boot. note that AT32AP7001 by default uses segment translation, as described in the avr 32 architecture manual. the 32 bit physical address space is mapped as follows: accesses to unused areas returns an error result to the master requesting such an access. the bus matrix has the several masters and slaves. each master has its own bus and its own decoder, thus allowing a different memory mapping per master. the master number in the table below can be used to index the hmatrix contro l registers. for example, mcfg2 is associated with the hsb-hsb bridge. table 9-1. AT32AP7001 physical memory map start address size device 0x0000_0000 64 mbyte ebi sram cs0 0x0400_0000 64 mbyte ebi sram cs4 0x0800_0000 64 mbyte ebi sram cs2 0x0c00_0000 64 mbyte ebi sram cs3 0x1000_0000 256 mbyte ebi sram/sdram cs1 0x2000_0000 64 mbyte ebi sram cs5 0x2400_0000 16 kbyte internal sram 0 0x2400_4000 16 kbyte internal sram1 0xff00_0000 4 kbyte lcdc configuration 0xff20_0000 1 kbyte dmac configuration 0xff30_0000 1 mbyte usb data 0xffe0_0000 1 mbyte pba 0xfff0_0000 1 mbyte pbb
72 32015a?avr32?02/07 AT32AP7001 each slave has its own arbiter, thus allowing a different arbitration per slave. the slave number in the table below can be used to index the hmatrix control registers. for example, scfg3 is associated with pbb. table 9-2. hsb masters master 0 cpu dcache master 1 cpu icache master 2 hsb-hsb bridge master 3 isi dma master 4 usb dma master 5 lcd controller dma master 6 ethernet mac0 dma master 7 ethernet mac1 dma master 8 dmac master interface 0 master 9 dmac master interface 1 table 9-3. hsb slaves slave 0 internal sram 0 slave 1 internal sram1 slave 2 pba slave 3 pbb slave 4 ebi slave 5 usb data slave 6 lcdc configuration slave 7 dmac configuration
73 32015a?avr32?02/07 AT32AP7001 10. peripherals 10.1 peripheral address map table 10-1. peripheral address mapping address peripheral name bus 0xff200000 dmac dma controller slave interface- dmac hsb 0xff300000 usb usb 2.0 slave interface - usb hsb 0xffe00000 spi0 serial peripheral interface - spi0 pb a 0xffe00400 spi1 serial peripheral interface - spi1 pb a 0xffe00800 twi two-wire interface - twi pb a 0xffe00c00 usart0 universal synchronous asynchronous receiver transmitter - usart0 pb a 0xffe01000 usart1 universal synchronous asynchronous receiver transmitter - usart1 pb a 0xffe01400 usart2 universal synchronous asynchronous receiver transmitter - usart2 pb a 0xffe01800 usart3 universal synchronous asynchronous receiver transmitter - usart3 pb a 0xffe01c00 ssc0 synchronous serial controller - ssc0 pb a 0xffe02000 ssc1 synchronous serial controller - ssc1 pb a 0xffe02400 ssc2 synchronous serial controller - ssc2 pb a 0xffe02800 pioa parallel input/output 2 - pioa pb a 0xffe02c00 piob parallel input/output 2 - piob pb a 0xffe03000 pioc parallel input/output 2 - pioc pb a 0xffe03400 piod parallel input/output 2 - piod pb a 0xffe03800 pioe parallel input/output 2 - pioe pb a
74 32015a?avr32?02/07 AT32AP7001 10.2 interrupt r equest signal map the various modules may output interrupt request signals. these signals are routed to the inter- rupt controller (intc). the interrupt controller supports up to 64 groups of interrupt requests. each group can have up to 32 interrupt request signals. all interrupt signals in the same group share the same autovector address and priority level. refer to the documentation for the individ- ual submodules for a description of the semantic of the different interrupt requests. 0xffe03c00 psif ps2 interface - psif pb a 0xfff00000 sm system manager - sm pb b 0xfff00400 intc interrupt controller - intc pb b 0xfff00800 hmatrix hsb matrix - hmatrix pb b 0xfff00c00 tc0 timer/counter - tc0 pb b 0xfff01000 tc1 timer/counter - tc1 pb b 0xfff01400 pwm pulse width modulation controller - pwm pb b 0xfff02000 dac dac - audio dac pb b 0xfff02400 mci mulitmedia card interface - mci pb b 0xfff02800 ac97c ac97 controller - ac97c pb b 0xfff02c00 isi image sensor interface - isi pb b 0xfff03000 usb usb 2.0 configuration interface - usb pb b 0xfff03400 smc static memory controller - smc pb b 0xfff03800 sdramc sdram controller - sdramc pb b 0xfff03c00 ecc error correcting code controller - ecc pb b table 10-1. peripheral address mapping (continued) address peripheral name bus
75 32015a?avr32?02/07 AT32AP7001 the interrupt request signals in at32ap700 1 are connected to the intc as follows: table 10-2. interrupt request signal map group line signal 0 0 count-compare match 1 performance counter overflow 2 0 dmac block 1 dmac dstt 2dmac err 3 dmac srct 4dmac tfr 3 0 spi 0 4 0 spi 1 50twi 6 0 usart0 7 0 usart1 8 0 usart2 9 0 usart3 10 0 ssc0 11 0 ssc1 12 0 ssc2 13 0 pioa 14 0 piob 15 0 pioc 16 0 piod 17 0 pioe 18 0 psif 19 0 eim0 1eim1 2eim2 3eim3 20 0 pm 21 0 rtc 22 0 tc00 1tc01 2tc02 23 0 tc10 1tc11 2tc12
76 32015a?avr32?02/07 AT32AP7001 10.3 dmac handshake interface map the following table details the hardware h andshake map between the dmac and the peripher- als attached to it: : 24 0 pwm 27 0 dac 28 0 mci 29 0 ac97c 30 0 isi 31 0 usb 32 0 ebi table 10-2. interrupt request signal map group line signal table 10-3. hardware handshaking connection request hardware handshaking interface mci rx 0 mci tx 1 dac tx 2 ac97c channel a rx 3 ac97c channel a tx 4 ac97c channel b rx 5 ac97c channel b tx 6 external dma request 0 7 external dma request 1 8 external dma request 2 9 external dma request 3 10
77 32015a?avr32?02/07 AT32AP7001 10.4 clock connections 10.4.1 timer/counters each timer/counter channel can independently select an internal or external clock source for its counter: 10.4.2 usarts each usart can be connected to an internally divided clock: table 10-4. timer/counter clock connections timer/counter source name connection 0 internal timer_clock1 clk_slow timer_clock2 clk_pbb / 4 timer_clock3 clk_pbb / 8 timer_clock4 clk_pbb / 16 timer_clock5 clk_pbb / 32 external xc0 see section 10.7 xc1 xc2 1 internal timer_clock1 clk_slow timer_clock2 clk_pbb / 4 timer_clock3 clk_pbb / 8 timer_clock4 clk_pbb / 16 timer_clock5 clk_pbb / 32 external xc0 see section 10.7 xc1 xc2 table 10-5. usart clock connections usart source name connection 0 internal clk_div clk_pba / 8 1 2 3
78 32015a?avr32?02/07 AT32AP7001 10.4.3 spis each spi can be connected to an internally divided clock: 10.5 external inte rrupt pin mapping external interrupt requests are connected to the following pins:: 10.6 nexus ocd aux port connections if the ocd trace system is enabled, the trace system will take control over a number of pins, irre- spectively of the pio configuration. two different ocd trace pi n mappings are possible, depending on the configuration of the ocd axs register. for details, see the avr32 ap techni- cal reference manual. table 10-6. spi clock connections spi source name connection 0 internal clk_div clk_pba / 32 1 table 10-7. external interrupt pin mapping source connection nmi_n pb24 extint0 pb25 extint1 pb26 extint2 pb27 extint3 pb28 table 10-8. nexus ocd aux port connections pin axs=0 axs=1 evti_n evti_n evti_n mdo[5] pb09 pc18 mdo[4] pb08 pc14 mdo[3] pb07 pc12 mdo[2] pb06 pc11 mdo[1] pb05 pc06 mdo[0] pb04 pc05 evto_n pb03 pb28 mcko pb02 pc02 mseo[1] pb01 pc01 mseo[0] pb00 pc00
79 32015a?avr32?02/07 AT32AP7001 10.7 peripheral multiplexing on io lines the AT32AP7001 features five pio controllers, pioa to pioe, that multiplex the i/o lines of the peripheral set. each pio controller controls up to thirty-two lines. each line can be assigned to one of two peripheral functions, a or b. the tables in the following pages define how the i/o lines of the peripherals a and b are multiplexed on the pio controllers. note that some output only peripheral func tions might be duplicated within the tables. 10.7.1 pio controller a multiplexing table 10-9. pio controller a multiplexing i/o line peripheral a peripheral b pa00 spi0 - miso ssc1 - rx_frame_sync pa01 spi0 - mosi ssc1 - tx_frame_sync pa02 spi0 - sck ssc1 - tx_clock pa03 spi0 - npcs[0] ssc1 - rx_clock pa04 spi0 - npcs[1] ssc1 - tx_data pa05 spi0 - npcs[2] ssc1 - rx_data pa06 twi - sda usart0 - rts pa07 twi - scl usart0 - cts pa08 psif - clock usart0 - rxd pa09 psif - data usart0 - txd pa10 mci - clk usart0 - clk pa11 mci - cmd tc0 - clk0 pa12 mci - data[0] tc0 - a0 pa13 mci - data[1] tc0 - a1 pa14 mci - data[2] tc0 - a2 pa15 mci - data[3] tc0 - b0 pa16 usart1 - clk tc0 - b1 pa17 usart1 - rxd tc0 - b2 pa18 usart1 - txd tc0 - clk2 pa19 usart1 - rts tc0 - clk1 pa20 usart1 - cts spi0 - npcs[3] pa21 ssc0 - rx_frame_sync pwm - pwm[2] pa22 ssc0 - rx_clock pwm - pwm[3] pa23 ssc0 - tx_clock tc1 - a0 pa24 ssc0 - tx_frame_sync tc1 - a1 pa25 ssc0 - tx_data tc1 - b0 pa26 ssc0 - rx_data tc1 - b1 pa27 spi1 - npcs[3] tc1 - clk0 pa28 pwm - pwm[0] tc1 - a2
80 32015a?avr32?02/07 AT32AP7001 10.7.2 pio controller b multiplexing pa29 pwm - pwm[1] tc1 - b2 pa30 sm - gclk[0] tc1 - clk1 pa31 sm - gclk[1] tc1 - clk2 table 10-9. pio controller a multiplexing table 10-10. pio controller b multiplexing i/o line peripheral a peripheral b pb00 isi - data[0] spi1 - miso pb01 isi - data[1] spi1 - mosi pb02 isi - data[2] spi1 - npcs[0] pb03 isi - data[3] spi1 - npcs[1] pb04 isi - data[4] spi1 - npcs[2] pb05 isi - data[5] spi1 - sck pb06 isi - data[6] mci - cmd[1] pb07 isi - data[7] mci - data[4] pb08 isi - hsync mci - data[5] pb09 isi - vsync mci - data[6] pb10 isi - pclk mci - data[7] pb11 psif - clock[1] isi - data[8] pb12 psif - data[1] isi - data[9] pb13 ssc2 - tx_data isi - data[10] pb14 ssc2 - rx_data isi - data[11] pb15 ssc2 - tx_clock usart3 - cts pb16 ssc2 - tx_frame_sync usart3 - rts pb17 ssc2 - rx_frame_sync usart3 - txd pb18 ssc2 - rx_clock usart3 - rxd pb19 sm - gclk[2] usart3 - clk pb20 dac - data[1] ac97c - sdo pb21 dac - data[0] ac97c - sync pb22 dac - datan[1] ac97c - sclk pb23 dac - datan[0] ac97c - sdi pb24 nmi_n dmac - dmarq[0] pb25 extint0 dmac - dmarq[1] pb26 extint1 usart2 - rxd pb27 extint2 usart2 - txd pb28 extint3 usart2 - clk pb29 sm - gclk[3] usart2 - cts pb30 sm - gclk[4] usart2 - rts
81 32015a?avr32?02/07 AT32AP7001 10.7.3 pio controller c multiplexing table 10-11. pio controller c multiplexing pc16 pc17
82 32015a?avr32?02/07 AT32AP7001 10.7.4 pio controller e multiplexing table 10-12. pio controller e multiplexing i/o line peripheral a peripheral b pe00 ebi - data[16] pe01 ebi - data[17] pe02 ebi - data[18] pe03 ebi - data[19] pe04 ebi - data[20] pe05 ebi - data[21] pe06 ebi - data[22] pe07 ebi - data[23] pe08 ebi - data[24] pe09 ebi - data[25] pe10 ebi - data[26] pe11 ebi - data[27] pe12 ebi - data[28] pe13 ebi - data[29] pe14 ebi - data[30] pe15 ebi - data[31] pe16 ebi - addr[23] pe17 ebi - addr[24] pe18 ebi - addr[25] pe19 ebi - cfce1 pe20 ebi - cfce2 pe21 ebi - ncs[4] pe22 ebi - ncs[5] pe23 ebi - cfrnw pe24 ebi - nwait pe25 ebi - ncs[2] pe26 ebi - sdcs
83 32015a?avr32?02/07 AT32AP7001 10.7.5 io pins without multiplexing many of the external ebi pins are not controlled by the pio modules, but directly driven by the ebi. these pins have programmable pullup resistor s. these resistors are controlled by special function register 4 (sfr4) in the hmatrix. the pullup on the lines multiplexed with pio is controlled by the appropriate pio control register. this sfr can also control compactflash, smartmedia or nandflash support, see the ebi chap- ter for details 10.7.5.1 hmatrix sfr4 ebi control register name: hmatrix_sfr4 access type: read/write ? cs1a: chip select 1 assignment 0 = chip select 1 is assigned to the static memory controller. 1 = chip select 1 is assign ed to the sdram controller. ? cs3a: chip select 3 assignment 0 = chip select 3 is only assigned to the static memory contro ller and ncs3 behaves as defined by the smc. 1 = chip select 3 is assigned to the static memory controller and the nand flash/smartmedia logic is activated. ? cs4a: chip select 4 assignment 0 = chip select 4 is assigned to the stat ic memory controller and ncs4, ncs5 and ncs6 behave as defined by the smc. 1 = chip select 4 is assigned to the static memory controller and the compactflash logic is activated. ? cs5a: chip select 5 assignment 0 = chip select 5 is assigned to the stat ic memory controller and ncs4, ncs5 and ncs6 behave as defined by the smc. 1 = chip select 5 is assigned to the static memory controller and the compactflash logic is activated. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????ebi_dbpuc 76543210 ? ? ebi_cs5a ebi_cs4a ebi_cs3a ? ebi_cs1a -
84 32015a?avr32?02/07 AT32AP7001 accessing the address space reserved to ncs5 and ncs6 may lead to an unpredictable outcome. ? ebi_dbpuc: ebi data bus pull-up control 0: ebi d[15:0] are internally pulled up to the vddio power supply. the pull-up resistors are enabled after reset. 1: ebi d[15:0] are not internally pulled up. table 10-13. io pins without multiplexing i/o line function px00 ebi - data[0] px01 ebi - data[1] px02 ebi - data[2] px03 ebi - data[3] px04 ebi - data[4] px05 ebi - data[5] px06 ebi - data[6] px07 ebi - data[7] px08 ebi - data[8] px09 ebi - data[9] px10 ebi - data[10] px11 ebi - data[11] px12 ebi - data[12] px13 ebi - data[13] px14 ebi - data[14] px15 ebi - data[15] px16 ebi - addr[0] px17 ebi - addr[1] px18 ebi - addr[2] px19 ebi - addr[3] px20 ebi - addr[4] px21 ebi - addr[5] px22 ebi - addr[6] px23 ebi - addr[7] px24 ebi - addr[8] px25 ebi - addr[9] px26 ebi - addr[10] px27 ebi - addr[11] px28 ebi - addr[12] px29 ebi - addr[13] px30 ebi - addr[14] px31 ebi - addr[15]
85 32015a?avr32?02/07 AT32AP7001 px32 ebi - addr[16] px33 ebi - addr[17] px34 ebi - addr[18] px35 ebi - addr[19] px36 ebi - addr[20] px37 ebi - addr[21] px38 ebi - addr[22] px39 ebi - ncs[0] px40 ebi - ncs[1] px41 ebi - ncs[3] px42 ebi - nrd px43 ebi - nwe0 px44 ebi - nwe1 px45 ebi - nwe3 px46 ebi - sdck px47 ebi - sdcke px48 ebi - ras px49 ebi - cas px50 ebi - sdwe px51 ebi - sda10 px52 ebi - nandoe px53 ebi - nandwe table 10-13. io pins without multiplexing (continued)
86 32015a?avr32?02/07 AT32AP7001 10.8 peripheral overview 10.8.1 external bus interface ? optimized for application memory space support ? integrates three external memory controllers: ? static memory controller ? sdram controller ? ecc controller ? additional logic for nand flash/smartmedia tm and compactflash tm support ? smartmedia support: 8-bit as well as 16-bit devices are supported ? compactflash support: all modes (attribute memory, common memory, i/o, true ide) are supported but the signal s _iois16 (i/o and true ide modes) and _ata sel (true ide mode) are not handled. ? optimized external bus: ? 16- or 32-bit data bus ? up to 26-bit address bus, up to 64-mbytes addressable ? optimized pin multiplexing to redu ce latencies on external memories ? up to 6 chip selects, configurable assignment: ? static memory controller on ncs0 ? sdram controller or static memory controller on ncs1 ? static memory controller on ncs2 ? static memory controller on ncs 3, optional nand flash/smartmedia tm support ? static memory controller on ncs 4 - ncs5, optional compactflash tm support 10.8.2 static memory controller ? 6 chip selects available ? 64-mbyte address space per chip select ? 8-, 16- or 32-bit data bus ? word, halfword, byte transfers ? byte write or by te select lines ? programmable setup, pulse and hold ti me for read signals per chip select ? programmable setup, pulse and hold time for write signals per chip select ? programmable data float time per chip select ? compliant with lcd module ? external wait request ? automatic switch to slow clock mode ? asynchronous read in page mode supporte d: page size ranges from 4 to 32 bytes 10.8.3 sdram controller ? numerous configurations supported ? 2k, 4k, 8k row address memory parts ? sdram with two or four internal banks ? sdram with 16- or 32-bit data path ? programming facilities ? word, half-word, byte access ? automatic page break when memory boundary has been reached ? multibank ping-pong access ? timing parameters specified by software ? automatic refresh operation, refresh rate is programmable
87 32015a?avr32?02/07 AT32AP7001 ? energy-saving capabilities ? self-refresh, power-down and deep power modes supported ? supports mobile sdram devices ? error detection ? refresh error interrupt ? sdram power-up initialization by software ? cas latency of 1, 2, 3 supported ? auto precharge command not used 10.8.4 error corrected code controller ? hardware error corrected code (ecc) generation ? detection and correction by software ? supports nand flash and smartmedia ? devices with 8- or 16-bit data path. ? supports nand flash/smartmedia with page size s of 528, 1056, 2112 and 4224 bytes, specified by software 10.8.5 serial peripheral interface ? supports communication with serial external devices ? four chip selects with extern al decoder support allow co mmunication with up to 15 peripherals ? serial memories, such as da taflash? and 3-wire eeproms ? serial peripherals, such as adcs, dacs, l cd controllers, can controllers and sensors ? external co-processors ? master or slave serial peripheral bus interface ? 8- to 16-bit programmable da ta length per chip select ? programmable phase and polarity per chip select ? programmable transfer delays between consecutive transfers and between clock and data per chip select ? programmable delay between consecutive transfers ? selectable mode fault detection ? very fast transfers supported ? transfers with baud rates up to mck ? the chip select line may be left active to speed up transfer s on the same device 10.8.6 two-wire interface ? compatibility with standard two-wire serial memory ? one, two or three bytes for slave address ? sequential read/write operations
88 32015a?avr32?02/07 AT32AP7001 10.8.7 usart ? programmable baud rate generator ? 5- to 9-bit full-duplex synchronous or asynchronous serial communications ? 1, 1.5 or 2 stop bits in a synchronous mode or 1 or 2 stop bits in synchronous mode ? parity generation and error detection ? framing error detection, overrun error detection ? msb- or lsb-first ? optional break generation and detection ? by 8 or by-16 over-sampling receiver frequency ? hardware handshaking rts-cts ? receiver time-out and transmitter timeguard ? optional multi-drop mode with address generation and detection ? optional manchester encoding ? rs485 with driver control signal ? iso7816, t = 0 or t = 1 protocols for interfacing with smart cards ? nack handling, error counter with repetition and iteration limit ? irda modulation and demodulation ? communication at up to 115.2 kbps ? test modes 46 ? remote loopback, local loopback, automatic echo 10.8.8 serial synchronous controller ? provides serial synchronous communication links used in audio and tel ecom applications (with codecs in master or slave modes, i2s, tdm buses, magnetic card reader, etc.) ? contains an independent receiver and transmitter and a common clock divider ? offers a configurable frame sync and data length ? receiver and transmitter can be programmed to st art automatically or on detection of different event on the frame sync signal ? receiver and transmitter include a data signal, a cloc k signal and a frame synchronization signal 10.8.9 ac97 controller ? compatible with ac97 comp onent specification v2.2 ? capable to interface with a single analog front end ? three independent rx channels and three independent tx channels ? one rx and one tx channel dedicated to the ac97 analog front end control ? one rx and one tx channel for data transfers, connected to the dmac ? one rx and one tx channel for data transfers, connected to the dmac ? time slot assigner allowing to assign up to 12 time slots to a channel ? channels support mono or stereo up to 20 bit sample length - variable sampling rate ac97 codec interface (48khz and below)
89 32015a?avr32?02/07 AT32AP7001 10.8.10 audio dac ? digital stereo dac ? oversampled d/a conversion architecture ? oversampling ratio fixed 128x ? fir equalization filter ? digital interpolation filter: comb4 ? 3rd order sigma-delta d/a converters ? digital bitstream outputs ? parallel interface ? connected to dma controller for backgrou nd transfer without cpu intervention 10.8.11 timer counter ? three 16-bit timer counter channels ? wide range of functions including: ? frequency measurement ? event counting ? interval measurement ? pulse generation ? delay timing ? pulse width modulation ? up/down capabilities ? each channel is user-conf igurable and contains: ? three external clock inputs ? five internal clock inputs ? two multi-purpose input/output signals ? two global registers that ac t on all three tc channels 10.8.12 pulse width modulation controller ? 4 channels, one 16-bit counter per channel ? common clock generator, providing thirteen different clocks ? a modulo n counter providing eleven clocks ? two independent linear dividers working on modulo n counter outputs ? independent channel programming ? independent enable disable commands ? independent clock ? independent period and duty cycle, with double bufferization ? programmable selection of the output waveform polarity ? programmable center or left aligned output waveform
90 32015a?avr32?02/07 AT32AP7001 10.8.13 multimedia card interface ? 2 double-channel multimedia card interface, allowing concurrent transfers with 2 cards ? compatibility with multimedia card specification version 2.2 ? compatibility with sd memory card specification version 1.0 ? compatibility with sdio specification version v1.0. ? cards clock rate up to master clock divided by 2 ? embedded power management to slow down clock rate when not used ? each mci has two slot, each supporting ? one slot for one multimediacard bus (up to 30 cards) or ?one sd memory card ? support for stream, block and multi-block data read and write 10.8.14 ps/2 keyboard interface ? peripheral bus slave ? ps/2 host ? receive and transmit capability ? parity generation and error detection ? overrun error detection 10.8.15 usb device port ? usb v2.0 high-speed compli ant, 480 mbits per second ? embedded usb v2.0 high-speed transceiver ? embedded dual-port ram for endpoints ? suspend/resume logic ? ping-pong mode (two memory banks) for isochronous and bulk endpoints ? six general-purpose endpoints ? endpoint 0, endpoint 3: 8 bytes, no ping-pong mode ? endpoint 1, endpoint 2: 64 bytes, ping-pong mode ? endpoint 4, endpoint 5: 256 bytes, ping-pong mode ? 10.8.16 image sensor interface ? itu-r bt. 601/656 8-bit mode external interface support ? support for itu-r bt.656-4 sav and eav synchronization ? vertical and horizontal re solutions up to 2048 x 2048 ? preview path up to 640*480 ? support for packed data formatting for ycbcr 4:2:2 formats ? preview scaler to generate smaller size image 50 ? programmable frame capture rate
91 32015a?avr32?02/07 AT32AP7001 11. power manager rev: 1.0.2.1 11.1 features ? controls oscillators and pll?s ? generates clocks and resets for digital logic ? supports 2 crystal oscillators 10 to 27 mhz ? supports 2 pll?s 80 to 150 mhz ? supports 32khz ultra-low power oscillator ? on-the fly frequency change of cpu, hsb, and pb frequency ? sleep modes allow simple disabling of logic clocks, pll?s and oscillators ? module-level clock gating through maskable peripheral clocks ? wake-up from interrupts or external pin ? generic clocks with wide frequency range provided ? automatic identificat ion of reset sources 11.2 description the power manager (pm) controls the oscillators, pll?s, and generates the clocks and resets in the device. the pm controls two fast crystal oscillators, as well as two pll?s, which can multiply the clock from either oscillato r to provide higher frequencies. additionally, a low-power 32khz oscillator is used to generate a slow clock for real-time counters. the provided clocks are divided into synchr onous and generic clocks. the synchronous clocks are used to clock the main digital logic in the device, namely the cpu, and the modules and peripherals connected to the hsb, pba, and pbb buses. the generic clocks are asynchronous clocks, which can be tuned precisely within a wide frequency range, which makes them suitable for peripherals that require specific frequencies, such as timers and communication modules. the pm also contains advanced power-saving feat ures, allowing the user to optimize the power consumption for an application. the synchronous cl ocks are divided into four clock domains, for the cpu, and modules on the h sb, pba, and pbb buses. the fo ur clocks can run at different speeds, so the user can save power by running pe ripherals at a relatively low clock, while main- taining a high cpu performance. additionally, the clocks can be independently changed on-the fly, without halting any peripherals. this enables the user to adjust the speed of the cpu and memories to the dynamic load of the applicati on, without disturbing or re-configuring active peripherals. each module also has a separate clock, enabling t he user to switch off the clock for inactive modules, to save further power. additionally, clocks and oscillators can be automatically swith- ced off during idle periods by using the sleep instruction on the cpu. the system will return to normal on occurence of interrupts or an event on the wake_n pin. the power manager also cointains a reset contro ller, which collects all possible reset sources, generates hard and soft resets, and allows the reset source to be identifed by software.
92 32015a?avr32?02/07 AT32AP7001 11.3 block diagram sleep controller oscillator and pll control pll0 pll1 synchronous clock generator generic clock generator reset controller oscillator 0 oscillator 1 32 khz oscillator startup counter slow clock sleep instruction oscen_n wake_n reset_n power-on detector soft reset sources resets generic clocks synchronous clocks osc/pll control signals
93 32015a?avr32?02/07 AT32AP7001 11.4 product dependencies 11.4.1 i/o lines the pm provides a number of generic clock out puts, which can be connected to output pins, multiplexed with pio lines. the programmer must first program the pio controller to assign these pins to their peripheral function. if the i/o pins of the pm are not used by the application, they can be used for other purposes by the pio controller. the pm also has a dedicated w ake_n pin, as well as a number of pins for oscillators and pll?s, which do not require the pio controller to be programmed. 11.4.2 interrupt the pm interrupt line is connected to one of the internal sources of the interrupt controller. using the pm interrupt requires the interrupt controller to be programmed first. 11.5 functional description 11.5.1 oscillator 0 and 1 operation the two main oscillators are designed to be used with an external 10 to 27 mhz crystal, as shown in figure 11-1 . the main oscillators are enabled by default after reset, and are only switched off in sleep modes, as described in section 11.5.6 on page 99 . after a power-on reset, or when waking up from a sleep mode that disabled the main os cillators, the oscillators need 128 slow clock cycles to stabilize on the corr ect frequency. the pm masks the main oscillator outputs during this start-up period, to ensure that no unstable clocks propagate to the digital logic. the oscillators can be bypassed by pulling the os cen_n pin high. this disables the oscillators, and an external clock must be applied on xin. no start-up time applies to this clock. figure 11-1. oscillator connections 11.5.2 32 khz oscillator operation the 32 khz oscillator operates similarly to oscillator 0 and 1 described above, and is used to generate the slow clock in the device. a 32768 hz crystal must be connected between xin32 and xout32 as shown in figure 11-1 . the 32 khz oscillator is is an ultra-low power design, and remains enabled in all sleep modes except static mode, as described in section 11.5.6 on page 99 . the oscillator has a rather lo ng start-up time of 32768 cloc k cycles, and no clocks will be generated in the device during this start-up time. xin xout c 2 c 1
94 32015a?avr32?02/07 AT32AP7001 note that in static sl eep mode the star tup counter will start at the neg edge of reset and not at the posedge. pulling oscen_n high will also disable the 32 khz oscillator, and a 32 khz clock must be applied on the xin32 pin. no start-up time applies to this clock. 11.5.3 pll operation the device contains two pll?s, pll0 and pll1. these are disabled by default, but can be enabled to provide high frequency source clocks for synchronous or generic clocks. the pll?s can take either oscillator 0 or 1 as clock source. each pll has an input divider, which divides the source clock, creating the reference clock for the pll. the pll output is divided by a user- defined factor, and the pll compares the resulting clock to the reference cl ock. the pll will adjust its output frequency until the two compar ed clocks are equal, thus locking the output fre- quency to a multiple of the reference clock frequency. when the pll is switched on, or when changing the clock source or multiplication or division factor for the pll, the pll is unlocked and the output frequency is undefined. the pll clock for the digital logic is automatically masked when th e pll is unlocked, to prevent connected digital logic from receiving a too high frequency and thus become unstable.
95 32015a?avr32?02/07 AT32AP7001 figure 11-2. pll with control logic and filters 11.5.3.1 enabling the pll plln is enabled by writing the pllen bit in th e plln register. pllosc selects oscillator 0 or 1 as clock source. the plldiv and pllmul bitfields must be written with the division and multipli- cation factor, respectively, creating the pll frequency: f pll = (pllmul+1)/(plldiv+1) ? f osc the lockn flag in isr is set when plln become s locked. the bit will stay high until cleared by writing 1 to icr:lockn. the po wer manager interrupt can be tr iggered by writing ier:lockn to 1. 11.5.3.2 lock suppression when using high division or multiplication factors, there is a possibility that the pll can give false lock indications while sweeping to the corr ect frequency. to prevent false lock indications from setting the lockn flag, the lock indication can be suppressed for a number of slow clock pll output divider input divider lft 0 1 osc0 clock osc1 clock pllosc pllen pllopt pllmul plldiv lock suppression pllcount lock mask pll clock c 1 r 1 c 2
96 32015a?avr32?02/07 AT32AP7001 cycles indicated in the plln:count field. typi cal start-up times can be found using the atmel filter caluclator (see below). 11.5.3.3 operating range selection to use plln, a passive rc filter should be connected to the lftn pin, as shown in figure 11-2 . filter values depend on the pll reference and output frequency range. atmel provides a tool named ?atmel pll lft filter calculator at91? available for download at the atmel web site. the pll for AT32AP7001 can be selected in this tool by selecting ?at91rm9200 (58a07f)? and leave ?icp = ?1?? (default). similarly, the plln:pllopt field should be set to proper values according to the pll operating frequency, as described in section 11.6.4 on page 108 . 11.5.4 synchronous clocks oscillator 0 (default) or pll0 prov ides the source for the main cl ocks, which is the common root for the synchronous clocks for the cpu, and hsb, pba, and pbb modules. the main clock is divided by an 8-bit prescaler, and each of these four synchronous clocks can run from any tap- ping of this prescaler, or the undivided main clock, as long as f cpu f hsb f pba, . the synchronous clock source can be changed on-the fly, responding to varying load in the applica- tion. the clock domains can be shut down in sleep mode, as described in ?sleep modes? on page 99 . additionally, the clocks for each module in the four domains can be individually masked, to avoid power consumption in inactive modules. figure 11-3. synchronous clock generation mask prescaler 0 1 osc0 clock pll0 clock pllsel 0 1 cpusel cpudiv main clock sleep controller cpumask cpu clocks hsb clocks pbaclocks pbb clocks sleep instruction
97 32015a?avr32?02/07 AT32AP7001 11.5.4.1 selecting pll or os cillator for the main clock the common main clock can be c onnected to oscillator 0 or pll0 . by default, the main clock will be connected to the osc illator 0 output. the user can connec t the main clock to the pll0 output by writing the pllsel bit in the main clock cont rol register (mcctrl) to 1. this must only be done after pll0 has been enabled, otherwise a deadlock will occur. care should also be taken that the new frequency of the synchronous clocks does not exceed the maximum frequency for each clock domain. 11.5.4.2 selecting synchronous clock division ratio the main clock feeds an 8-bit prescaler, which can be used to generate the synchronous clocks. by default, the synchronous clocks run on the undivided main clock. the user can select a pres- caler division for the cpu clock by writing c ksel:cpudiv to 1 and cpusel to the prescaling value, resulting in a cpu clock frequency: f cpu = f main / 2 (cpusel+1) similarly, the clock for hsb, pba, and pbb can be divided by writing their respective bitfields. to ensure correct operation, frequencies must be selected so that f cpu f hsb f pba,b . also, fre- quencies must never exceed the specified maximum frequency for each clock domain. cksel can be written without hal ting or disabling peripheral m odules. writing cksel allows a new clock setting to be written to all synchronous clocks at the sa me time. it is possible to keep one or more clocks unchanged by writing the same value a before to the xxxdiv and xxxsel bit- fields. this way, it is possible to e.g. scale cpu and hsb speed according to the required performance, while keeping the pba and pbb frequency constant. 11.5.4.3 clock ready flag there is a slight delay from cksel is written and the new clock setting becomes effective. dur- ing this interval, the clock ready (c krdy) flag in isr will read as 0. if ier:ckrdy is written to 1, the power manager interrupt can be triggered when the new clock setting is effective. cksel must not be re-written while ckrdy is 0, or the system may become unstable or hang. 11.5.5 peripheral clock masking by default, the clock for all modules are enabled, regardless of which modules are actually being used. it is possible to disable the clock for a module in the cpu, hsb, pba, or pbb clock domain by writing the corresponding bit in the clock mask register (cpu/hsb/pba/pbb) to 0. when a module is not clocked, it will cease operation, and its re gisters cannot be read or written. the module can be re-enabled later by writing the corresponding mask bit to 1. a module may be connected to several clock domains, in which case it will have several mask bits. table 11-1 contains a list of impl emented maskable clocks. 11.5.5.1 cautionary note note that clocks should only be switched off if it is certain that the module will not be used. switching off the clock for the internal ram will cause a pr oblem if the stack is mapped there. switching off the clock to the system manager (sm), which contains the mask registers, or the corresponding pb bridge, will make it impossible to write the mask registers again. in this case, they can only be re-enabled by a system reset.
98 32015a?avr32?02/07 AT32AP7001 11.5.5.2 mask ready flag due to synchronization in the clock generator, there is a slight delay from a mask register is writ- ten until the new mask setting goes into effect. when clearing mask bits, this delay can usually be ignored. however, when setting mask bits, the registers in the corresponding module must not be written until the clock has actually be re-enabled. the status flag mskrdy in isr pro- vides the required mask status information. when wr iting either mask register with any value, this bit is cleared. the bit is set when the clocks have been enabled and disabled according to the new mask setting. optionally, the power ma nager interrupt can be enabled by writing the mskrdy bit in ier.
99 32015a?avr32?02/07 AT32AP7001 11.5.6 sleep modes in normal operation, all clock domains are active, allowing software execution and peripheral operation. when the cpu is idle, it is possible to switch off the cpu clock and optionally other clock domains to save power. this is activate d by the sleep instruction, which takes the sleep mode index number as argument. 11.5.6.1 entering and exiting sleep modes the sleep instruction will halt the cpu and all modules belonging to t he stopped clock domains. the modules will be halted regardless of th e bit settings of the mask registers. oscillators and pll?s can also be switched off to save power. these modules have a relatively long start-up time, and are only switched off when very low power consumption is required. the cpu and affected modules are restarted when the sleep mode is exited. this occurs when an interrupt trigge rs, or the wake_n pin is asserted. no te that even though an interrupt is enabled in sleep mode, it may not trigger if the source module is not clocked. table 11-1. maskable module cl ocks in AT32AP7001. bit cpumask hsbmask pbamask pbbmask 0 pico ebi spi0 sm 1 - pba spi1 intc 2 - pbb twi hmatrix 3 - hramc usart0 tc0 4 - hsb-hsb bridge usart1 tc1 5 - isi usart2 pwm 6 - usb usart3 macb0 7 - lcdc ssc0 macb1 8 - macb0 ssc1 dac 9 - macb1 ssc2 mci 10 - dma pioa ac97c 11 - - piob isi 12 - - pioc usb 13 - - piod smc 14 - - pioe sdramc 15 - - psif ecc 16 - - pdc - 31: 17 ----
100 32015a?avr32?02/07 AT32AP7001 11.5.6.2 supported sleep modes the following sleep modes are supported. these are detailed in table 11-2 . ?idle: the cpu is stopped, the rest of the chip is operating. wake-up sources are any interrupt, or wake_n pin. ?frozen: the cpu and hsb modules are stopped, peripherals are operating. wake-up sources are any interr upt from pb modules, or wake_n pin. ?standby: all synchronous clocks are stopped, but oscillators and pll?s are running, allowing quick wake-up to normal mode. wake-up sources are rtc or external interrupt, or wake_n pin. ?stop: as standby, but oscilla tor 0 and 1, and the pll?s are stopped. 32 khz oscillator and rtc/wdt still operates. wake-up sources are rtc or external inte rrupt, or wake_n pin. ?static: all oscillators and clocks are stoppe d. wake-up sources are external interrupt or wake_n pin.? 11.5.6.3 precautions when entering sleep mode modules communicating with external circuits should normally be disabled before entering a sleep mode that will stop the mo dule operation. this prevents erra tic behavior when entering or exiting sleep mode. please refer to the re levant module documentation for recommended actions. communication between the synchronous clock domains is disturbed when entering and exiting sleep modes. this means that bus transactions are not allowed between clock domains affected by the sleep mode. the system may hang if th e bus clocks are stopped in the middle of a bus transaction. the cpu and caches are automatically stopped in a safe state to ensure that all cpu bus oper- ations are complete when the sleep mode goes into effect. thus, when entering idle mode, no further action is necessary. when entering a deeper sleep mode than idle mode, all other hsb masters must be stopped before entering the sleep mode. also, if there is a chance that any pb write operations are incomplete, the cpu should perform a read operation from any register on the pb bus before executing the sleep instruction. this will stal l the cpu while waiting for any pending pb opera- tions to complete. the power manager will leave some clocks running if the ocd is in debug mode or there is a memory access instruction loaded in the jtag. to ensure that the correct sleep mode is exe- table 11-2. sleep modes index sleep mode cpu hsb pba,b + gclk osc0,1 + pll0,1 osc32 + rtc/wdt 0 idle off on on on on 1frozenoffoffononon 2 standby off off off on on 3 stop off off off off on 5 static off off off off off
101 32015a?avr32?02/07 AT32AP7001 cuted debug mode should be turned off and the idcode instruction should be loaded into the instruction register of the jtag. 11.5.7 generic clocks timers, communication modules, and other modules connected to external circuitry may require specific clock frequencies to operate correctly . the power manager contains an implementation defined number of generic clocks, that can prov ide a wide range of accurate clock frequencies. each generic clock module runs from either oscilla tor 0 or 1, or pll0 or 1. the selected source can optionally be divided by any even integer up to 512. each clock can be independently enabled and disabled, and is also automatically disabled along with peripheral clocks by the sleep controller. figure 11-4. generic clock generation 11.5.7.1 enabling a generic clock a generic clock is enabled by writi ng the cen bit in gcctrl to 1. each generic clock can use either oscillator 0 or 1 or pll0 or 1 as source, as select ed by the pllsel and oscsel bits. the source clock can optionally be divided by writing diven to 1 and the division factor to div, resulting in the output frequency: f gclk = f src / (2*(div+1)) 11.5.7.2 disabling a generic clock the generic clock can be disabled by writing cen to 0 or entering a sleep mode that disables the pb clocks. in either case, the generic clock will be switched off on the first falling edge after the disabling event, to ensu re that no glitches occur. if cen is written to 0, the bit will still read as 1 until the next falling edge occu rs, and the clock is actually sw itched off. when writing cen to 0, the other bits in gcctrl should not be changed until cen reads as 0, to avoid glitches on the generic clock. when the clock is disabled, both the prescaler and output are reset. divider 0 1 osc0 clock pll0 clock pllsel oscsel osc1 clock pll1 clock generic clock div 0 1 diven mask cen sleep controller
102 32015a?avr32?02/07 AT32AP7001 11.5.7.3 changing clock frequency when changing generic clock frequency by writing gcctrl, the clock should be switched off by the procedure above, before being re-enabled with the new clock source or division setting. this prevents glitches during the transition. 11.5.7.4 generic clock implementation in AT32AP7001, there are 8 generic clocks. these are allocated to different functions as shown in table 11-3 . 11.5.8 divided pb clocks the clock generator in the power manager pr ovides divided pba and pbb clocks for use by peripherals that require a prescaled pb clock. this is described in the documentation for the rel- evant modules. the divided clocks are not directly maskable, but are stopped in sleep modes where the pb clocks are stopped. 11.5.9 debug operation during a debug session, the user may need to halt the system to inspect memory and cpu reg- isters. the clocks normally keep running during this debug opera tion, but some peripherals may require the clocks to be stopped, e.g. to prevent timer overflow, which would cause the program to fail. for this reason, peripherals on the pba and pbb buses may use ?debug qualified? pb clocks. this is described in t he documentation for the relevant modules. the divided pb clocks are always debug qualified clocks. debug qualified pb clocks are stopped duri ng debug operation. the debug system can option- ally keep these clocks running during the debug operation. this is described in the documentation for the on-chip debug system. table 11-3. generic clock allocation clock number function 0gclk0 pin 1gclk1 pin 2gclk2 pin 3gclk3 pin 4gclk4 pin 5 reserved for internal use 6dac 7 lcd controller
103 32015a?avr32?02/07 AT32AP7001 11.5.10 reset controller the reset controller collects the various reset sources in the system and generates hard and soft resets for the digital logic. the device contains a power-on detector, which keeps the system reset until power is stable. this eliminates the need for external reset circuitry to guarantee stable operation when powering up the device. it is also possible to reset the device by asserting the reset_n pin. this pin has an internal pul- lup, and does not need to be driven externally when negated. table 11-4 lists these and other reset sources supported by the reset controller. figure 11-5. reset controller block diagram reset sources are divided into hard and soft resets. hard resets imply that the system could have become unstable, and virtually all logic will be reset. t he clock generator, which also con- trols the oscillators, will also be reset. if the device is reset due to a power-on reset, or reset occurred when the device was in a sleep mode that disabled the oscillators , the normal oscillator startup time will apply. a soft reset will reset most digital logic in t he device, such as cpu, hsb, and pb modules, but not the ocd system, clock generator, watchdog timer and rtc, allowing some functions, including the oscillators, to remain active during the reset. the startup time from a soft reset is thus negligible. note that all pb registers are reset, except those in the rtc/wdt. the mcctrl and cksel registers are reset, and the devic e will restart using oscillator 0 as clock source for all synchronous clocks. in addition to the listed reset types, the jtag can keep parts of the device statically reset through the jtag reset register. see jtag documentation for details. ntae reset controller reset_n power-on detector dbr watchdog reset rc_rcause hard reset soft reset cpu, hsb, pba, pbb ocd, rtc/wdt, clock generator
104 32015a?avr32?02/07 AT32AP7001 the cause of the last reset can be read from the rc_rcause register. this register contains one bit for each reset source, and can be identified during the boot sequence of an application to determine the proper action to be taken. table 11-4. reset types reset source description type power-on reset supply voltage below the power-on reset detector threshold voltage hard external reset_n pin asserted hard nanotrace access error see on-chip debug documentation. soft watchdog timer see watchdog timer documentation. soft ocd see on-chip debug documentation soft
105 32015a?avr32?02/07 AT32AP7001 11.6 user interface 11.6.1 main clock control name: mcctrl access type: read/write offset register register name access reset 0x00 main clock control mcctrl read/write 0x0 0x04 clock select cksel read/write 0x0 0x08 cpu clock mask cpumask read/write impl. defined 0x0c hsb clock mask hsbmask read/write impl. defined 0x10 pba clock mask pbamask read/write impl. defined 0x14 pbb clock mask pbbmask read/write impl. defined 0x20 pll0 control pll0 read/write 0x0 0x24 pll1 control pll1 read/write 0x0 0x40 interrupt enable ier write-only 0x0 0x44 interrupt disable idr write-only 0x0 0x48 interrupt mask imr read-only 0x0 0x4c interrupt status isr read-only 0x0 0x50 interrupt clear icr write-only 0x0 0x60 generic clock control 0 gcctrl0 read/write 0x0 0x64 generic clock control 1 gcctrl1 read/write 0x0 0x68 generic clock control 2 gcctrl2 read/write 0x0 0x6c generic clock control 3 gcctrl3 read/write 0x0 0x70 generic clock control 4 gcctrl4 read/write 0x0 0x74 generic clock control 5 gcctrl5 read/write 0x0 0x78 generic clock control 6 gcctrl6 read/write 0x0 0x7c generic clock control 7 gcctrl7 read/write 0x0 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8
106 32015a?avr32?02/07 AT32AP7001 ? pllsel: pll select 0: oscillator 0 is source for the main clock 1: pll0 is source for the main clock 11.6.2 clock select name: cksel access type: read/write ? pbbdiv, pbbsel: pbb divi sion and clock select pbbdiv = 0: pbb clock equals main clock. pbbdiv = 1: pbb clock equals main clock divided by 2 (pbbsel+1) . ? pbadiv, pbasel: pba division and clock select pbadiv = 0: pba clock equals main clock. pbadiv = 1: pba clock equals main clock divided by 2 (pbasel+1) . ? hsbdiv, hsbsel: hsb divi sion and clock select hsbdiv = 0: hsb clock equals main clock. hsbdiv = 1: hsb clock equals main clock divided by 2 (hsbsel+1) . ? cpudiv, cpusel: cpu divi sion and clock select cpudiv = 0: cpu clock equals main clock. cpudiv = 1: cpuclock equals main clock divided by 2 (cpusel+1) . note that if xxxdiv is written to 0, xxxsel should also be written to 0 to ensure correct operation. also note that writing this register clears isr:ckrdy. the register must not be re-written until ckrdy goes high. -------- 76543210 ------pllsel- 31 30 29 28 27 26 25 24 pbbdiv - - - - pbbsel 23 22 21 20 19 18 17 16 pbadiv - - - - pbasel 15 14 13 12 11 10 9 8 hsbdiv - - - - hsbsel 76543210 cpudiv - - - - cpusel
107 32015a?avr32?02/07 AT32AP7001 11.6.3 clock mask name: cpu/hsb/pba/pbbmask access type: read/write ? mask: clock mask if bit n is cleared, the clock for module n is stopped. if bit n is set, the clock for module n is enabled according to the cur rent power mode. the number of implemented bits in each mask register, as well as which module clock is controlled by each bit, is implementation dependent. 31 30 29 28 27 26 25 24 mask[31:24] 23 22 21 20 19 18 17 16 mask[23:16] 15 14 13 12 11 10 9 8 mask[15:8] 76543210 mask[7:0]
108 32015a?avr32?02/07 AT32AP7001 11.6.4 pll control name: pll0,1 access type: read/write ? plltest: pll test reserved for internal use. always write to 0. ? pllcount: pll count specifies the number of slow clock cycles before isr:lockn will be set after plln has been written, or after plln has been automatically re-enabled after exiting a sleep mode. ? pllmul: pll multiply factor ? plldiv: pll division factor these bitfields determine the ratio of the pll out put frequency to the source oscillator frequency: f pll = (pllmul+1)/(plldiv+1) ? f osc ? pllopt: pll option select the operating range for the pll. note: operation beyond the maximum clock speed is not implied. 100: 80-160 mhz 110: 150-200mhz other values: reserved ? pllosc: pll os cillator select 0: oscillator 0 is t he source for the pll. 1: oscillator 1 is t he source for the pll. ? pllopt: pll option 0: pll is disabled. 1: pll is enabled. 31 30 29 28 27 26 25 24 plltest - pllcount 23 22 21 20 19 18 17 16 pllmul 15 14 13 12 11 10 9 8 plldiv 76543210 - - - pllopt pllosc pllen
109 32015a?avr32?02/07 AT32AP7001 11.6.5 interrupt enable/disable/mask/status/clear name: ier/idr/imr/isr/icr access type: ier/idr/icr: write-only imr/isr: read-only ? mskrdy: mask ready 0: either xxxmask register has b een written, and clocks are not yet enabled or disabled according to the new mask value. 1: clocks are enabled and disabled as indicated in the xxxmask registers. note: writing icr:mskrdy to 1 has no effect. ? ckrdy: clock ready 0: the cksel register has been written, and the new clock setting is not yet effective. 1: the synchronous clocks have frequencies as indicated in the cksel register. note: writing icr:ckrdy to 1 has no effect. ? vmrdy, vok these bits are for internal use only. in isr, the value of thes e bits is undefined. in ier, these bits should be written to 0. ? wake: wake pin asserted 0: the wake_n pin is not asserted, or has been asserted for less than one pb clock period. 1: the wake_n pin is asserted for longer than one pb clock period. ? lock1: pll1 locked ? lock0: pll0 locked 0: the pll is unlocked, and cannot be used as clock source. 1: the pll is locked, and can be used as clock source. the effect of writing or reading the bits listed above depends on which register is being accessed: ? ier (write-only) 0: no effect 1: enable interrupt ? idr (write-only) 0: no effect 1: disable interrupt 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - mskrdy ckrdy vmrdy vok wake lock1 lock0
110 32015a?avr32?02/07 AT32AP7001 ? imr (read-only) 0: interrupt is disabled 1: interrupt is enabled ? isr (read-only) 0: an interrupt event has occurred 1: an interrupt even has not occurred ? icr (write-only) 0: no effect 1: clear interrupt event
111 32015a?avr32?02/07 AT32AP7001 11.6.6 generic clock control name: gcctrl0... gcctrl7 access type: read/write there is one gcctrl register per generic clock in the design. ? div: division factor ? diven: divide enable 0: the generic clock equals the undivided source clock. 1: the generic clock equals the source clock divided by 2*(div+1). ? cen: clock enable 0: clock is stopped. 1: clock is running. ? pllsel: pll select 0: oscillator is source for the generic clock. 1: pll is source for the generic clock. ? oscsel: oscillator select 0: oscillator (or pll) 0 is source for the generic clock. 1: oscillator (or pll) 1is source for the generic clock. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 div[7:0] 76543210 - - - diven - cen pllsel oscsel
112 32015a?avr32?02/07 AT32AP7001 11.6.7 reset cause name: rc_rcause access type: read-only ? ntae: nanotrace access error this bit is set if a reset occurred due to a nanotrace access error. ? wdt: watchdog timer this bit is set if a reset occurred due to a timeout of the watchdog timer. ? ext: external reset this bit is set if a reset occurred due to assertion of the reset_n pin. ? por: power-on detector this bit is set if a reset was caused by the power-on detector. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - ntae wdt ext - por
113 32015a?avr32?02/07 AT32AP7001 12. real time counter rev: 1.0.1 12.1 features ? 32-bit real-time counte r with 16-bit prescaler ? clocked from 32 khz oscillator ? high resoluti on: max count frequency 16khz ? long delays ? max timeout 272 years ? extremely low power consumption ? available in all sleep modes except deepdown ? optional wrap at max value ? interrupt on wrap 12.2 description the real time counter (rtc) enables periodic in terrupts at long intervals, or accurate mea- surement of real-time sequences. the rtc is fed from a 16-bit prescaler, which is clocked from the 32 khz oscillator. any tapping of the prescaler can be select ed as clock source for the rtc, enabling both high resolution and long timeouts. the prescaler cannot be written directly, but can be cleared by the user. the rtc can generate an interrupt when the counter wraps around the top value of 0xffffffff. optionally, the rtc can wrap at a lower value, producing accurate periodic interrupts. 12.3 block diagram figure 12-1. real time counter module block diagram 12.4 product dependencies 12.4.1 i/o lines none. 16-bit prescaler 32 khz 32-bit counter rtc_val rtc_top topi irq
114 32015a?avr32?02/07 AT32AP7001 12.4.2 power management the rtc is continously clocked, and remains operating in all sleep modes except deepdown. 12.4.3 interrupt the rtc interrupt line is connected to one of the internal sources of the interrupt controller. using the rtc interrupt requires the interrupt controller to be programmed first. 12.4.4 debug operation the rtc prescaler and watchdog timer are frozen during debug operation, unless the ocd sys- tem keeps peripherals running in debug operation. 12.5 functional description 12.5.1 rtc operation 12.5.1.1 source clock the rtc is enabled by writing the en bit in the ctrl register. this also enables the clock for the prescaler. the psel bitfield in the same register selects th e prescaler tapping, selecting the source clock for the rtc: f rtc = 2 -(psel+1) * 32khz 12.5.1.2 counter operation the rtc count value can be read from or written to the register val. the prescaler cannot be written directly, but can be reset by writing the strobe pclr in ctrl. when enabled, the rtc will then up -count until it reac hes 0xffffffff, and then wrap to 0x0. writing ctrl:topen to one causes the rtc to wrap at the value written to top. the status bit topi in isr is set when this occurs. 12.5.1.3 rtc interrupt writing the topi bit in ier enab les the rtc interr upt, while writing the corresponding bit in idr disables the rtc interrupt. imr can be read to see whether or not the interrupt is enabled. if enabled, an interrupt will be gener ated if the topi flag in isr is set. the flag can be cleared by writing topi in icr to one.
115 32015a?avr32?02/07 AT32AP7001 12.6 user interface offset register register name access reset 0x00 rtc control ctrl read/write 0x0 0x04 rtc value val read/write 0x0 0x08 rtc top top read/write 0x0 0x10 rtc interrupt enable ier write-only 0x0 0x14 rtc interrupt disable idr write-only 0x0 0x18 rtc interrupt mask imr read-only 0x0 0x1c rtc interrupt status isr read-only 0x0 0x20 rtc interrupt clear icr write-only 0x0
116 32015a?avr32?02/07 AT32AP7001 12.6.1 rtc control name: ctrl access type: read/write ? psel: prescale select selects prescaler bit psel as source clock for the rtc. ? topen: top enable 0: rtc wraps at 0xffffffff 1: rtc wraps at rtc_top ? pclr: prescaler clear writing this strobe clears the prescaler. note that this also resets the watchdog timer. ? en: enable 0: rtc is disabled 1: rtc is enabled 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - psel[3:0] 76543210 - - - - - topen pclr en
117 32015a?avr32?02/07 AT32AP7001 12.6.2 rtc value name: val access type: read/write ? val: rtc value this value is incremented on every rising edge of the source clock. 31 30 29 28 27 26 25 24 val[31:24] 23 22 21 20 19 18 17 16 val[23:16] 15 14 13 12 11 10 9 8 val[15:8] 76543210 val[7:0]
118 32015a?avr32?02/07 AT32AP7001 12.6.3 rtc top name: top access type: read/write ? top: rtc top value val wraps at this value if ctrl:topen is 1. 31 30 29 28 27 26 25 24 top[31:24] 23 22 21 20 19 18 17 16 top[23:16] 15 14 13 12 11 10 9 8 top[15:8] 76543210 top[7:0]
119 32015a?avr32?02/07 AT32AP7001 12.6.4 rtc interrupt enable/disable/mask/status/clear name: ier/idr/imr/isr/icr access type: ier/idr/icr: write-only imr/isr: read-only ? topi: top interrupt val has wrapped at its top. the effect of writing or reading this bit depends on which register is being accessed: ? ier (write-only) 0: no effect 1: enable interrupt ? idr (write-only) 0: no effect 1: disable interrupt ? imr (read-only) 0: interrupt is disabled 1: interrupt is enabled ? isr (read-only) 0: an interrupt event has not occurred 1: an interrupt event has occurred. note that this is only set when the rtc is configured to wrap at top. ? icr (write-only) 0: no effect 1: clear interrupt event 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------topi
120 32015a?avr32?02/07 AT32AP7001 13. watchdog timer rev: 1.0.1 13.1 features ? watchdog timer with 16-bit prescaler 13.2 description the watchdog timer (wdt) is fed from a 16-bit pr escaler, which is clocked from the 32 khz oscillator. any tapping of the pr escaler can be selected as cloc k source for the wdt.the watch- dog timer must be periodically reset by software within the timeout period, ot herwise, the device is reset and starts executing from the boot vector. this allows the device to recover from a con- dition that has caused the system to be unstable. 13.3 block diagram figure 13-1. real time counter module block diagram 13.4 product dependencies 13.4.1 i/o lines none 13.4.2 power management the wdt is continously clocked, and remains ope rating in all sleep modes. however, if the wdt is enabled and the user tries to enter a sl eepmode where the 32 khz oscillator is turned off the system will enter the stop slee pmode instead. this is to en sure the wdt is still running. 13.4.3 debug operation the watchdog timer is frozen during debug operati on, unless the ocd system keeps peripherals running in debug operation. 16-bit p rescaler 32 khz wdt_clr w atchdog detector wdt_ctrl w atchdog reset
121 32015a?avr32?02/07 AT32AP7001 13.5 functional description 13.5.1 watchdog timer the wdt is enabled by writing the en bit in the ctrl register. this also enables the clock for the prescaler. the psel bitfield in the same register selects the watchdog ti meout period: t wdt = 2 (psel+1) * 30.518 s to avoid accidental disabling of the watchdog, the ctrl register must be written twice, first with the key field set to 0x55, then 0xaa without changing the other bitfields. failure to do so will cause the write operation to be ignored, and ctrl does not change value. the clr register must be written with any value with regular intervals shorter than the watchdog timeout period. otherwise, the device will receive a soft reset, and the code will start executing from the boot vector.
122 32015a?avr32?02/07 AT32AP7001 13.6 user interface 13.6.1 wdt control name: ctrl access type: read/write ? key this bitfield must be written twice, first with key value 0x55, then 0xaa, for a write operation to be effective. this bitfield always reads as zero. ? psel: prescale select prescaler bit psel is used as watchdog ti meout period. ? en: wdt enable 0: wdt is disabled. 1: wdt is enabled. offset register register name access reset 0x30 wdt control ctrl read/write 0x0 0x34 wdt clear clr write-only 0x0 31 30 29 28 27 26 25 24 key[7:0] 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - - psel[3:0] 76543210 -------en
123 32015a?avr32?02/07 AT32AP7001 13.6.2 wdt clear name: clr access type: write-only when the watchdog timer is enabled, this register must be periodically written, with any value, within the watchdog timeout period, to prevent a watchdog reset.
124 32015a?avr32?02/07 AT32AP7001 14. interrupt controller 14.1 description the intc collects interrupt requests from the peripherals, prioritizes them, and delivers an inter- rupt request and an autovector to the cpu. the avr32 architecture supports 4 priority levels for regular, maskable interrupts, and a non-maskable interrupt (nmi). the intc supports up to 64 groups of interrupts. each group can have up to 32 interrupt request lines, these lines are connected to the peripherals. each group has an interrupt priority register (ipr) and an interrupt request register (irr). the iprs are used to assign a priority level and an autovector to each group, and the irrs are used to identify the active interrupt request within each group. if a group has only one interrupt request line, an active interrupt group uniquely identifies the active interrupt request line, and the corresponding irr is not needed. the intc also provides one interrupt cause register (icr) per priority level. these registers identify the group that has a pending interrupt of the corresponding priority level. if several groups have an pending interrupt of the same level, the group with the highest number takes priority. 14.2 block diagram figure 14-1 on page 124 gives an overview of the intc. the grey boxes represent registers that can be accessed via the peripheral bus (pb). the interrupt requests from the peripherals (ireqn) and the nmi are input on the left side of the figure. signals to and from the cpu are on the right side of the figure. figure 14-1. overview of the interrupt controller 14.3 operation all of the incoming interrupt requests (ireqs) are sampled into the corresponding interrupt request register (irr). the irrs must be accessed to identify which ireq within a group that is active. if several ireqs within the same group is active, the interrupt service routine must pri- oritize between them. all of the input lines in each group are logically-ored together to form the grpreqn lines, indicating if there is a pending interrupt in the corresponding group. request masking or ireq0 ireq1 ireq2 ireq31 grpreq0 masks sreg masks i[3-0]m gm intlevel autovector prioritizer cpu interrupt controller or grpreqn nmireq or ireq32 ireq33 ireq34 ireq63 grpreq1 irr registers ipr registers icr registers int_level, offset int_level, offset int_level, offset ipr0 ipr1 iprn irr0 irr1 irrn valreq0 valreq1 valreqn
125 32015a?avr32?02/07 AT32AP7001 the request masking hardware maps each of the grpreq lines to a priority level from int0 to int3 by associating each group with the intlevel field in the corresponding ipr register. the grpreq inputs are then masked by the i0m, i1m, i2m, i3m and gm mask bits from the cpu sta- tus register. any interrupt group that has a pending interrupt of a priority level that is not masked by the cpu status register, gets its corresponding valreq line asserted. the prioritizer hardware uses th e valreq lines and the intlevel fi eld in the iprs to select the pending interrupt of the highest priority. if a nmi interrupt is pending, it automatically gets high- est priority of any pending interrupt. if several interrupt groups of the highest pending interrupt level have pending interrupts, the interrupt group with the highest number is selected. interrupt level (intlevel) and han dler autovector offset (autovec tor) of the selected inter- rupt are transmitted to the cpu for interrupt handling and context switching. the cpu doesn't need to know which interrupt is requesting handling, but only the level and the offset of the han- dler address. the irr registers contain the interr upt request lines of the groups and can be read via pb for checking which interrupts of the group are actually active. masking of the interrupt requests is done based on five interrupt mask bits of the cpu status register, namely interrupt level 3 mask (i3m) to interrupt level 0 mask (i0m), and global interrupt mask (gm). an interrupt request is masked if either the global interrupt mask or the correspond- ing interrupt level mask bit is set. 14.3.1 non maskable interrupts a nmi request has priority over all other interrupt requests. nmi has a dedicated exception vec- tor address defined by the avr32 archit ecture, so autovector is undefined when intlevel indicates that an nmi is pending. 14.3.2 cpu response when the cpu receives an interr upt request it checks if any othe r exceptions are pending. if no exceptions of higher priority are pending, interr upt handling is initiated. when initiating interrupt handling, the corresponding interrupt mask bit is se t automatically for this and lower levels in sta- tus register. e.g, if interrupt on level 3 is approved for handling the interrupt mask bits i3m, i2m, i1m, and i0m are set in status register. if interrupt on level 1 is approved the masking bits i1m, and i0m are set in status register. the handler offset is calculated from autovector and evba and a change-of-fl ow to this address is performed. setting of the interrupt mask bits prevents the interrupts from the same and lower levels to be passed trough the interrupt controller. setting of the same level mask bit prevents also multiple request of the same interrupt to happen. it is the responsibility of the ha ndler software to clear the interrupt request that caused the inter- rupt before returning from the interrupt handler. if the conditions that caused the interrupt are not cleared, the interrupt request remains active. 14.3.3 clearing an interrupt request clearing of the interrupt request is done by writing to registers in the corresponding peripheral module, which then clears the corresponding nmireq/ireq signal. the recommended way of clearing an interrupt request is a store operation to the controlling peripheral register, followed by a dummy load operat ion from the same register. this causes a pipeline stall, which prevents the interrupt from accidentally re-triggering in case the handler is exited and the interrupt mask is cleared before the interrupt request is cleared.
126 32015a?avr32?02/07 AT32AP7001 14.4 user interface this chapter lists the intc registers are accessible through the pb bus. the registers are used to control the behaviour and read the status of the intc. 14.4.1 memory map the following table shows the address map of the intc registers, relative to the base address of the intc. 14.4.2 interrupt request map the mapping of interrupt requests from peripher als to intreqs is presented in the peripherals section. table 14-1. intc address map offset register name access reset value 0 interrupt priority regist er 0 ipr0 read/write 0x0000_0000 4 interrupt priority regist er 1 ipr1 read/write 0x0000_0000 ... ... ... ... ... 252 interrupt priority regist er 63 ipr63 read/write 0x0000_0000 256 interrupt request register 0 irr0 read-only n/a 260 interrupt request register 1 irr1 read-only n/a ... ... ... ... ... 508 interrupt request register 63 irr63 read-only n/a 512 interrupt cause register 3 icr3 read-only n/a 516 interrupt cause register 2 icr2 read-only n/a 520 interrupt cause register 1 icr1 read-only n/a 524 interrupt cause register 0 icr0 read-only n/a
127 32015a?avr32?02/07 AT32AP7001 14.4.3 interrupt request registers register name : irr0...irr63 access type: read-only ? irr: interrupt request line 0 = no interrupt request is pending on this input request input. 1 = an interrupt request is pending on this input request input. the are 64 irrs, one for each group. each irr has 32 bits, one for each possible interrupt request, for a total of 2048 pos- sible input lines. the irrs are read by the software interrupt handler in order to determine which interrupt request is pending. the irrs are sampled continuously, and are read-only. 31 30 29 28 27 26 25 24 irr(32*x+31) irr(32*x+30) irr(32*x+29) irr(32*x+28) ir r(32*x+27) irr(32*x+26) irr(32*x+25) irr(32*x+24) 23 22 21 20 19 18 17 16 irr(32*x+23) irr(32*x+22) irr(32*x+21) irr(32*x+20) ir r(32*x+19) irr(32*x+18) irr(32*x+17) irr(32*x+16) 15 14 13 12 11 10 9 8 irr(32*x+15) irr(32*x+14) irr(32*x+13) irr(32*x+12) ir r(32*x+11) irr(32*x+10) irr(32*x+9) irr(32*x+8) 76543210 irr(32*x+7) irr(32*x+6) irr(32*x+5) irr(32*x+4) i rr(32*x+3) irr(32*x+2) irr(32*x+1) irr(32*x+0)
128 32015a?avr32?02/07 AT32AP7001 14.4.4 interrupt priority registers register name : ipr0...ipr63 access type: read/write ? intlevel: interrupt level associated with this group indicates the evba-relative offs et of the interrupt handler of the corresponding group: ? autovector: autovector address for this group handler offset is used to give the address of the interrupt handler. the lsb should be written to zero to give halfword alignment 31 30 29 28 27 26 25 24 intlevel[1:0] ------ 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - autovector[13:8] 76543210 autovector[7:0] intlevel[1:0] priority 00int0 01int1 10int2 11int3
129 32015a?avr32?02/07 AT32AP7001 14.4.5 interrupt cause registers register name : icr0...icr3 access type: read-only ? cause: interrupt group causing interrupt of priority n icrn identifies the group with the highest priority that has a pending interrupt of level n. if no interrupts of level n are pe nd- ing, or the priority level is mask ed, the value of icrn is undefined. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -- cause
130 32015a?avr32?02/07 AT32AP7001 15. external interrupts rev: 1.0.0 15.1 features ? dedicated interrupt requ ests for each interrupt ? individually maskable interrupts ? interrupt on rising or falling edge ? interrupt on high or low level ? maskable nmi interrupt 15.2 description the external interrupt module allows 4 pins to be configured as external interrupts. each pin has its own interrupt request, and can be individually masked. each pin can generate an interrupt on rising or falling edge, or high or low level. the module also masks the nmi_n pin, which generates the nmi interrupt for the cpu. 15.3 block diagram figure 15-1. external interrupt module block diagram 15.4 product dependencies 15.4.1 i/o lines the external interrupt and nmi pins are multiplexed with pio lines. to act as external interrupts, these pins must be configured as inputs pins by th e pio controller. it is also possible to trigger the interrupt by driving these pins from registers in the pio controller, or another peripheral out- put connected to the same pin. sync edge/level detector mask irqn extintn intn eim_level eim_mode eim_ier eim_idr eim_icr eim_isr eim_imr nmi_n sync mask nmi_irq eim_nmic
131 32015a?avr32?02/07 AT32AP7001 15.4.2 power management edge triggered interrupts are available in al l sleep modes except deepdown. level triggered interrupts and the nmi interrupt are available in all sleep modes. 15.4.3 interrupt the eim interrupt lines are connected to internal sources of the interrupt controller. using the external interrutps requires the interrupt controller to be programmed first. using the non-maskable interrupt does not require the interrupt controller to be programmed. 15.5 functional description 15.5.1 external interrupts each external interrupt pin extintn can be configured to produce an interrupt on rising or fall- ing edge, or high or low level. external interrupts are configured by the eim_mode, eim_edge, and eim_level regi sters. each interrupt n has a bit intn in each of these registers. similarly, each interrupt has a corresponding bit in each of the interrupt control and status regis- ters. writing 1 to the intn strobe in eim_ier enables the external interrupt on pin extintn, while writing 1 to intn in eim_idr disables the external interrupt. eim_imr can be read to check which interrupts are enabled. when the interrupt triggers, the corresponding bit in eim_isr will be set. for edge triggered interrupt s, the flag remains set until the corresponding strobe bit in eim_icr is written to 1. for level triggered interrupts, the flag remains set for as long as the interrupt condition is present on the pin. writing intn in eim_mode to 0 enables edge triggered interrupts, while writing the bit to 1 enables level triggered interrupts. if extintn is configured as an ed ge triggered inte rrupt, writing in tn in eim_edge to 0 will trig- ger the interrupt on falling edge, while writing the bit to 1 will trigger the interr upt on risi ng edge. if extintn is configured as a le vel triggered interrupt, writing intn in eim_level to 0 will trig- ger the interrupt on low level, while writin g the bit to 1 will trigger the interrupt on high level. 15.5.1.1 synchronization of external interrupts the pin value of the extintn pins is normally sy nchronized to the cpu clo ck, so spikes shorter than a cpu clock cycle are not guaranteed to produce an interrupt. in stop mode, spikes shorter than a 32khz clock cycle are not guaranteed to produce an interrupt. in deepdown mode, only unsynchronized level interr upts remain active, and any short sp ike on this interrupt will wake up the device. 15.5.2 nmi control the non-maskable interrupt of the cpu is connected to the nmi_n pin through masking logic in the external interrupt module. this masking ensures that the nmi will not trigger before the cpu has been set up to handle interrupts. writing the en bit in the eim_nmic register enables the nmi interrupt, while writing en to 0 disables the nmi interrupt. when enabled, the interrupt trig- gers whenever the nmi_n pin is negated. the nmi_n pin is synchronized the same way as external level interrupts.
132 32015a?avr32?02/07 AT32AP7001 15.6 user interface offset register register name access reset 0x00 eim interrupt enable eim_ier write-only 0x0 0x04 eim interrupt disable eim_idr write-only 0x0 0x08 eim interrupt mask eim_imr read-only 0x0 0x0c eim interrupt status eim_isr read-only 0x0 0x10 eim interrupt clear eim_icr write-only 0x0 0x14 external interrupt mode eim_mode read/write 0x0 0x18 external interrupt edge eim_edge read/write 0x0 0x1c external interrupt le vel eim_level read/write 0x0 0x24 external interrupt nmi control eim_nmic read/write 0x0
133 32015a?avr32?02/07 AT32AP7001 15.6.1 eim interrupt enable/disable/mask/status/clear name: eim_ier/idr/imr/isr/icr access type: eim_ier/idr/icr: write-only eim_imr/isr: read-only ? intn: external interrupt n 0: external interrupt has not triggered 1: external interrupt has triggered the effect of writing or reading the bits listed above depends on which register is being accessed: ? ier (write-only) 0: no effect 1: enable interrupt ? idr (write-only) 0: no effect 1: disable interrupt ? imr (read-only) 0: interrupt is disabled 1: interrupt is enabled ? isr (read-only) 0: an interrupt event has occurred 1: an interrupt even has not occurred ? icr (write-only) 0: no effect 1: clear interrupt event 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - int3 int2 int1 int0
134 32015a?avr32?02/07 AT32AP7001 15.6.2 external interrupt mode/edge/level name: eim_mode/edge/level access type: read/write ? intn: external interrupt n the bit interpretation is register specific: ? eim_mode 0: interrupt is edge triggered 1: interrupt is level triggered ? eim_edge 0: interrupt triggers on falling edge 1: interrupt triggers on rising edge ? eim_level 0: interrupt triggers on low level 1: interrupt triggers on high level 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 - - - - int3 int2 int1 int0
135 32015a?avr32?02/07 AT32AP7001 15.6.3 nmi control name: eim_nmic access type: read/write ? en: enable 0: nmi disabled. asserting the nmi pi n does not generate an nmi request. 1: nmi enabled. asserting the nmi pin generate an nmi request. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 -------en
136 32015a?avr32?02/07 AT32AP7001 16. hsb bus matrix (hmatrix) rev: 2.2.0.0 16.1 features ? user interface on peripheral bus ? configurable number of masters (up to sixteen) ? configurable number of slaves (up to sixteen) ? one decoder for each master ? three different memory mappin gs for each master (interna l and external boot, remap) ? one remap function for each master ? programmable arbitration for each slave ? round-robin ? fixed priority ? programmable default master for each slave ? no default master ? last accessed default master ? fixed default master ? one cycle latency for the first access of a burst ? zero cycle latency for default master ? one special function register for each slave (not dedicated) 16.2 description the bus matrix implements a multi-layer bus structure, that enables parallel access paths between multiple high speed bus (hsb) masters and slaves in a system, thus increasing the overall bandwidth. the bus matrix interconnects up to 16 hsb masters to up to 16 hsb slaves. the normal latency to connect a master to a slave is one cycle except for the default master of the accessed slave which is connected directly (zero cycle latency). the bus matrix provides 16 special function registers (sfr) that allow the bus matrix to support application specific features. 16.3 memory mapping the bus matrix provides one decoder for every hsb master interface. the decoder offers each hsb master several memory mappings. in fact, depending on the product, each memory area may be assigned to several slaves. booting at the same address while using different hsb slaves (i.e. external ram, internal rom or internal flash, etc.) becomes possible. the bus matrix user interface provides master remap control register (mrcr) that performs remap action for every master independently. 16.4 special bus granting mechanism the bus matrix provides some speculative bus granting techniques in order to anticipate access requests from some masters. this mechanism reduc es latency at first access of a burst or single transfer. this bus granting mechanism sets a different default master for every slave. at the end of the current access, if no other re quest is pending, the slave remains connected to its associated default master. a slave can be as sociated with three kinds of default masters: no default master, last access master and fixed default master.
137 32015a?avr32?02/07 AT32AP7001 16.5 no default master at the end of the current access, if no other request is pending, the slave is disconnected from all masters. no default ma ster suits low-power mode. 16.6 last access master at the end of the current access, if no other re quest is pending, the slave remains connected to the last master that performed an access request. 16.7 fixed default master at the end of the current access, if no other r equest is pending, the slave connects to its fixed default master. unlike last access master, the fixed master does not change unless the user modifies it by a software action (field fixed_defmstr of the related scfg). to change from one kind of default master to another, the bus matrix user interface provides the slave configuration registers, one for each slave, that set a default master for each slave. the slave configuration register contains two fields: defmstr_type and fixed_defmstr. the 2-bit defmstr_type field selects the default mast er type (no default, last access master, fixed default master), whereas the 4-bit fixed_defmstr field selects a fixed default master pro- vided that defmstr_type is set to fixed default master. please refer to the bus matrix user interface description. 16.8 arbitration the bus matrix provides an arbitration mechanism that reduces latency when conflict cases occur, i.e. when two or more masters try to access the same slave at the same time. one arbiter per hsb slave is provided, thus ar bitrating each slave differently. the bus matrix provides the user with the possibility of choosing between 2 arbitration types for each slave: 1. round-robin arbitration (default) 2. fixed priority arbitration this choice is made via the field arbt of the slave configuration registers (scfg). each algorithm may be complemented by selecting a default master configuration for each slave. when a re-arbitration must be done, specific condi tions apply. see section 16.8.1 ?arbitration rules? on page 137 . 16.8.1 arbitration rules each arbiter has the ability to arbitrate between two or more different master requests. in order to avoid burst breaking and also to provide the maximum throughput for slave interfaces, arbitra- tion may only take place during the following cycles: 1. idle cycles: when a slave is not connected to any master or is connected to a master which is not currently accessing it. 2. single cycles: when a slave is currently doing a single access. 3. end of burst cycles: when the current cycle is the last cycle of a burst transfer. for defined length burst, predicted end of burst matches the size of the transfer but is man- aged differently for undefined length burst. see section ?16.8.1.1? on page 138.
138 32015a?avr32?02/07 AT32AP7001 4. slot cycle limit: when the slot cycle counte r has reached the limit value indicating that the current master access is too long and must be broken. see section ?16.8.1.2? on page 138. 16.8.1.1 undefined length burst arbitration in order to avoid long slave handling during unde fined length bursts (incr), the bus matrix pro- vides specific logic in order to re-arbitrate before the end of the incr transfer. a predicted end of burst is used as a defined length burst transfer and can be selected from among the following five possibilities: 1. infinite: no predicted end of burst is gen erated and therefore i ncr burst transfer will never be broken. 2. one beat bursts: predicted end of burst is generated at each single transfer inside the incp transfer. 3. four beat bursts: predicted end of burst is generated at the end of each four beat boundary inside incr transfer. 4. eight beat bursts: predicted end of burst is generated at the end of each eight beat boundary inside incr transfer. 5. sixteen beat bursts: predicted end of burst is generated at the end of each sixteen beat boundary inside incr transfer. this selection can be done through the field ulbt of the master configuration registers (mcfg). 16.8.1.2 slot cycle limit arbitration the bus matrix contains specific logic to break long accesses, such as very long bursts on a very slow slave (e.g., an external low speed memory). at the beginning of the burst access, a counter is loaded with the value previously written in the slot_cycle field of the related slave configuration register (scfg) and decreased at each clock cycle. when the counter reaches zero, the arbiter has the ability to re-arbitrate at the end of the current byte, half word or word transfer. 16.8.2 round-robin arbitration this algorithm allows the bus matrix arbiters to dispatch the requests from different masters to the same slave in a round-robin manner. if two or more master requests arise at the same time, the master with the lowest number is first serviced, then the others are serviced in a round-robin manner. there are three round-robin algorithms implemented: ? round-robin arbitration without default master ? round-robin arbitration with last default master ? round-robin arbitration with fixed default master 16.8.2.1 round-robin arbitration without default master this is the main algorithm used by bus matrix arbiters. it allows the bus matrix to dispatch requests from different masters to the same slave in a pure round-robin manner. at the end of the current access, if no other request is pending, the slave is disconnected from all masters. this configuration incurs one latency cycle for the first access of a burst. arbitration without default master can be used for masters that perform significant bursts.
139 32015a?avr32?02/07 AT32AP7001 16.8.2.2 round-robin arbitration with last default master this is a biased round-robin algorithm used by bus matrix arbiters. it allows the bus matrix to remove the one late ncy cycle for the last master that acce ssed the slave. in fact, at the end of the current transfer, if no other master request is pending, the slave remains connected to the last master that performed the access. other non priv ileged masters still get one latency cycle if they want to access the same slave. this technique can be used for masters that mainly perform single accesses. 16.8.2.3 round-robin arbitration with fixed default master this is another biased round-robin algorithm. it a llows the bus matrix arbiters to remove the one latency cycle for the fixed default master per slav e. at the end of the current access, the slave remains connected to its fixed default master. every request attempted by this fixed default mas- ter will not cause any latency whereas other non privileged masters w ill still get one latency cycle. this technique can be used for masters that mainly perform single accesses. 16.8.3 fixed priority arbitration this algorithm allows the bus matrix arbiters to dispatch the requests from different masters to the same slave by using the fixed priority defined by the user. if two or more master requests are active at the same time, the master with the highest priority number is serviced first. if two or more master requests with the same priority are active at the same time, the master with the highest number is serviced first. for each slave, the priority of each master may be defined through the priority registers for slaves (pras and prbs).
140 32015a?avr32?02/07 AT32AP7001 16.9 hsb generic bus ma trix user interface table 16-1. register mapping offset register name access reset value 0x0000 master configuration register 0 mcfg0 read/write 0x00000002 0x0004 master configuration register 1 mcfg1 read/write 0x00000002 0x0008 master configuration register 2 mcfg2 read/write 0x00000002 0x000c master configuration register 3 mcfg3 read/write 0x00000002 0x0010 master configuration register 4 mcfg4 read/write 0x00000002 0x0014 master configuration register 5 mcfg5 read/write 0x00000002 0x0018 master configuration register 6 mcfg6 read/write 0x00000002 0x001c master configuration register 7 mcfg7 read/write 0x00000002 0x0020 master configuration register 8 mcfg8 read/write 0x00000002 0x0024 master configuration register 9 mcfg9 read/write 0x00000002 0x0028 master configuration register 10 mcfg10 read/write 0x00000002 0x002c master configuration regi ster 11 mcfg11 read/write 0x00000002 0x0030 master configuration register 12 mcfg12 read/write 0x00000002 0x0034 master configuration register 13 mcfg13 read/write 0x00000002 0x0038 master configuration register 14 mcfg14 read/write 0x00000002 0x003c master configuration regi ster 15 mcfg15 read/write 0x00000002 0x0040 slave configuration register 0 scfg0 read/write 0x00000010 0x0044 slave configuration register 1 scfg1 read/write 0x00000010 0x0048 slave configuration register 2 scfg2 read/write 0x00000010 0x004c slave configuration register 3 scfg3 read/write 0x00000010 0x0050 slave configuration register 4 scfg4 read/write 0x00000010 0x0054 slave configuration register 5 scfg5 read/write 0x00000010 0x0058 slave configuration register 6 scfg6 read/write 0x00000010 0x005c slave configuration register 7 scfg7 read/write 0x00000010 0x0060 slave configuration register 8 scfg8 read/write 0x00000010 0x0064 slave configuration register 9 scfg9 read/write 0x00000010 0x0068 slave configuration register 10 scfg10 read/write 0x00000010 0x006c slave configuration register 11 scfg11 read/write 0x00000010 0x0070 slave configuration register 12 scfg12 read/write 0x00000010 0x0074 slave configuration register 13 scfg13 read/write 0x00000010 0x0078 slave configuration register 14 scfg14 read/write 0x00000010 0x007c slave configuration register 15 scfg15 read/write 0x00000010 0x0080 priority register a for slave 0 pras0 read/write 0x00000000 0x0084 priority register b for slave 0 prbs0 read/write 0x00000000 0x0088 priority register a for slave 1 pras1 read/write 0x00000000
141 32015a?avr32?02/07 AT32AP7001 0x008c priority register b for slave 1 prbs1 read/write 0x00000000 0x0090 priority register a for slave 2 pras2 read/write 0x00000000 0x0094 priority register b for slave 2 prbs2 read/write 0x00000000 0x0098 priority register a for slave 3 pras3 read/write 0x00000000 0x009c priority register b for slave 3 prbs3 read/write 0x00000000 0x00a0 priority register a for slave 4 pras4 read/write 0x00000000 0x00a4 priority register b for slave 4 prbs4 read/write 0x00000000 0x00a8 priority register a for slave 5 pras5 read/write 0x00000000 0x00ac priority register b for slave 5 prbs5 read/write 0x00000000 0x00b0 priority register a for slave 6 pras6 read/write 0x00000000 0x00b4 priority register b for slave 6 prbs6 read/write 0x00000000 0x00b8 priority register a for slave 7 pras7 read/write 0x00000000 0x00bc priority register b for slave 7 prbs7 read/write 0x00000000 0x00c0 priority register a for slave 8 pras8 read/write 0x00000000 0x00c4 priority register b for slave 8 prbs8 read/write 0x00000000 0x00c8 priority register a for slave 9 pras9 read/write 0x00000000 0x00cc priority register b for slave 9 prbs9 read/write 0x00000000 0x00d0 priority register a for slave 10 pras10 read/write 0x00000000 0x00d4 priority register b for slave 10 prbs10 read/write 0x00000000 0x00d8 priority register a for slave 11 pras11 read/write 0x00000000 0x00dc priority register b for slave 11 prbs11 read/write 0x00000000 0x00e0 priority register a for slave 12 pras12 read/write 0x00000000 0x00e4 priority register b for slave 12 prbs12 read/write 0x00000000 0x00e8 priority register a for slave 13 pras13 read/write 0x00000000 0x00ec priority register b for slave 13 prbs13 read/write 0x00000000 0x00f0 priority register a for slave 14 pras14 read/write 0x00000000 0x00f4 priority register b for slave 14 prbs14 read/write 0x00000000 0x00f8 priority register a for slave 15 pras15 read/write 0x00000000 0x00fc priority register b for slave 15 prbs15 read/write 0x00000000 0x0100 master remap control register mrcr read/write 0x00000000 0x0104 - 0x010c reserved ? ? ? 0x0110 special function register 0 sfr0 read/write ? 0x0114 special function register 1 sfr1 read/write ? 0x0118 special function register 2 sfr2 read/write ? 0x011c special function register 3 sfr3 read/write ? 0x0120 special function register 4 sfr4 read/write ? table 16-1. register mapping (continued) offset register name access reset value
142 32015a?avr32?02/07 AT32AP7001 0x0124 special function register 5 sfr5 read/write ? 0x0128 special function register 6 sfr6 read/write ? 0x012c special function register 7 sfr7 read/write ? 0x0130 special function register 8 sfr8 read/write ? 0x0134 special function register 9 sfr9 read/write ? 0x0138 special function register 10 sfr10 read/write ? 0x013c special function register 11 sfr11 read/write ? 0x0140 special function register 12 sfr12 read/write ? 0x0144 special function register 13 sfr13 read/write ? 0x0148 special function register 14 sfr14 read/write ? 0x014c special function register 15 sfr15 read/write ? 0x0150 - 0x01f8 reserved ? ? ? table 16-1. register mapping (continued) offset register name access reset value
143 32015a?avr32?02/07 AT32AP7001 16.10 bus matrix master configuration registers register name: mcfg0...mcfg15 access type: read/write ? ulbt: undefined length burst type 0: infinite length burst no predicted end of burst is generated and therefore incr bursts coming from this master cannot be broken. 1: single access the undefined length burst is treated as a succession of single accesses, allowing re-arbitration at each beat of the incr burst. 2: four beat burst the undefined length burst is split into a four-beat burst, allowing re-arbitration at each four-beat burst end. 3: eight beat burst the undefined length burst is split into an eight-beat burst, allowing re-arbitration at each eight-beat burst end. 4: sixteen beat burst the undefined length burst is split into a sixteen-beat burst, allowing re-arbitration at each sixteen-beat burst end. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????? ulbt
144 32015a?avr32?02/07 AT32AP7001 16.11 bus matrix slave configuration registers register name: scfg0...scfg15 access type: read/write ? slot_cycle: maximum number of allowed cycles for a burst when the slot_cycle limit is reached for a burst, it may be broken by another master tr ying to access this slave. this limit has been placed to avoid locking a very slow slave when very long bursts are used. this limit must not be very small. un reasonably small values break every burst and the bus matrix arbitrates without per- forming any data transfer. 16 cycles is a reasonable value for slot_cycle. ? defmstr_type: default master type 0: no default master at the end of the current slave access, if no other master request is pending, the slave is disconnected from all masters. this results in a one cycle latency for the first access of a burst transfer or for a single access. 1: last default master at the end of the current slave access, if no other master request is pending, the slave stays connected to the last master having accessed it. this results in not having one cycle latency when the last master tries to access the slave again. 2: fixed default master at the end of the current slave access, if no other master r equest is pending, the slave connec ts to the fixed master the number that has been written in the fixed_defmstr field. this results in not having one cycle latency when the fixed master tries to access the slave again. ? fixed_defmstr: fixed default master this is the number of the defa ult master for this slave. only used if defmstr_type is 2. specifying the number of a mas- ter which is not connected to the selected slave is equivalent to setting defmstr_type to 0. ? arbt: arbitration type 0: round-robin arbitration 1: fixed priority arbitration 31 30 29 28 27 26 25 24 ???????arbt 23 22 21 20 19 18 17 16 ? ? fixed_defmstr defmstr_type 15 14 13 12 11 10 9 8 ???????? 76543210 slot_cycle
145 32015a?avr32?02/07 AT32AP7001 16.12 bus matrix priority registers a for slaves register name: pras0...pras15 access type: read/write ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. 31 30 29 28 27 26 25 24 m7pr m6pr 23 22 21 20 19 18 17 16 m5pr m4pr 15 14 13 12 11 10 9 8 m3pr m2pr 76543210 m1pr m0pr
146 32015a?avr32?02/07 AT32AP7001 16.13 bus matrix priority registers b for slaves register name: prbs0...prbs15 access type: read/write ? mxpr: master x priority fixed priority of master x for accessing the selected slave. the higher the number, the higher the priority. 31 30 29 28 27 26 25 24 m15pr m14pr 23 22 21 20 19 18 17 16 m13pr m12pr 15 14 13 12 11 10 9 8 m11pr m10pr 76543210 m9pr m8pr
147 32015a?avr32?02/07 AT32AP7001 16.14 bus matrix master remap control register register name: mrcr access type: read/write reset: 0x0000_0000 ? rcb: remap command bit for master x 0: disable remapped address decoding for the selected master 1: enable remapped address decoding for the selected master 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rcb15 rcb14 rcb13 rcb12 rcb11 rcb10 rcb9 rcb8 76543210 rcb7 rcb6 rcb5 rcb4 rcb3 rcb2 rcb1 rcb0
148 32015a?avr32?02/07 AT32AP7001 16.15 bus matrix speci al function registers register name: sfr0...sfr15 access type: read/write reset: ? sfr: special function register fields the bitfields of these registers are described in the peripherals chapter. 31 30 29 28 27 26 25 24 sfr 23 22 21 20 19 18 17 16 sfr 15 14 13 12 11 10 9 8 sfr 76543210 sfr
149 32015a?avr32?02/07 AT32AP7001 17. external bus interface (ebi) rev: 1.0.0 17.1 features ? optimized for application memory space support ? integrates three external memory controllers: ? static memory controller ? sdram controller ? ecc controller ? additional logic for nand flash/smartmedia tm and compactflash tm support ? smartmedia support: 8-bit as well as 16-bit devices are supported ? compactflash support: all modes (attribute memory, common memory, i/o, true ide) are supported but the signal s _iois16 (i/o and true ide modes) and _ata sel (true ide mode) are not handled. ? optimized external bus: ? 16- or 32-bit data bus ? up to 26-bit address bus, up to 64-mbytes addressable ? optimized pin multiplexing to redu ce latencies on external memories ? up to 6 chip selects, configurable assignment: ? static memory controller on ncs0 ? sdram controller or static memory controller on ncs1 ? static memory controller on ncs2 ? static memory controller on ncs 3, optional nand flash/smartmedia tm support ? static memory controller on ncs 4 - ncs5, optional compactflash tm support 17.2 description the external bus interface (ebi) is designed to ensure the successful data transfer between several external devices and the embedded memory controller of an avr32 device. the static memory, sdram and ecc controllers are all featured external memory controllers on the ebi. these external memory controllers are capable of handling several types of external memory and peripheral devices, such as sram , prom, eprom, eeprom, flash, and sdram. the ebi also supports the compactflash and the nand flash/smartmedia protocols via inte- grated circuitry that greatly reduces the requirements for external components. furthermore, the ebi handles data transfers with up to six external devices, each assigned to six address spaces defined by the embedded memory controller. data transfers are performed through a 16-bit or 32-bit data bus, an address bus of up to 26 bits, up to six chip select lines (ncs[5:0]) and sev- eral control pins that are generally multip lexed between the different external memory controllers.
150 32015a?avr32?02/07 AT32AP7001 17.3 block diagram 17.3.1 external bus interface figure 17-1 shows the organization of the external bus interface. figure 17-1. organization of the external bus interface external bus interface 0 d[15:0] a[15:2], a[22:18] pio mux logic user interface chip select assignor static memory controller sdram controller bus matrix peripheral bus hsb address decoders a16/ba0 a0/nbs0 a1/nwr2/nbs2 a17/ba1 ncs0 ncs3/nandcs nrd/noe/cfoe ncs1/sdcs0 nwr0/nwe/cfwe nwr1/nbs1/cfior nwr3/nbs3/cfiow sdck sdcke ras cas sdwe d[31:16] a[25:23] cfrnw ncs4/cfcs0 ncs5/cfcs1 ncs2 cfce1 cfce2 nwait sda10 nandoe nandwe nand flash smartmedia logic compactflash logic ecc controller sdcs1
151 32015a?avr32?02/07 AT32AP7001 17.4 i/o lines description table 17-1. ebi i/o lines description name function type active level ebi d0 - d31 data bus i/o a0 - a25 address bus output nwait external wait signal input low smc ncs0 - ncs5 chip select lines output low nwr0 - nwr3 write signals output low noe output enable output low nrd read signal output low nwe write enable output low nbs0 - nbs3 byte mask signals output low ebi for compactflash support cfce1 - cfce2 compactflash chip enable output low cfoe compactflash output enable output low cfwe compactflash write enable output low cfior compactflash i/o read signal output low cfiow compactflash i/o write signal output low cfrnw compactflash read not write signal output cfcs0 - cfcs1 compactflash chip select lines output low ebi for nand flash/smartmedia support nandcs smartmedia chip select line output low nandoe smartmedia output enable output low nandwe smartmedia write enable output low sdram controller sdck sdram clock output sdcke sdram clock enable output high sdcs sdram controller chip select line output low ba0 - ba1 bank select output sdwe sdram write enable output low ras - cas row and column signal output low nwr0 - nwr3 write signals output low nbs0 - nbs3 byte mask signals output low sda10 sdram address 10 line output
152 32015a?avr32?02/07 AT32AP7001 depending on the memory controller in use, all signals are not connected directly through the mux logic. table 17-2 on page 152 details the connections between the two memory controllers and the ebi pins. table 17-2. ebi pins and memory controllers i/o lines connections ebi pins sdramc i/o lines smc i/o lines nwr1/nbs1/cfior nbs1 nwr1/nub a0/nbs0 not supported smc_a0/nlb a1/nbs2/nwr2 not supported smc_a1 a[11:2] sdramc_a[9:0] smc_a[11:2] sda10 sdramc_a10 not supported a12 not supported smc_a12 a[14:13] sdramc_a[12:11] smc_a[14:13] a[22:15] not supported smc_a[22:15] a[25:23] not supported smc_a[25:23] d[31:0] d[31:0] d[31:0]
153 32015a?avr32?02/07 AT32AP7001 17.5 application example 17.5.1 hardware interface table 17-3 on page 153 details the connections to be applied between the ebi pins and the external devices for each memory controller. notes: 1. nwr1 enables upper byte writes. nwr0 enables lower byte writes. 2. nwrx enables corresponding byte x writes. (x = 0,1,2 or 3) 3. nbs0 and nbs1 enable respectively lower and upper bytes of the lower 16-bit word. 4. nbs2 and nbs3 enable respectively lower and upper bytes of the upper 16-bit word. 5. bex: byte x enable (x = 0,1,2 or 3) table 17-3. ebi pins and external static devices connections signals pins of the interfaced device 8-bit static device 2 x 8-bit static devices 16-bit static device 4 x 8-bit static devices 2 x 16-bit static devices 32-bit static device controller smc d0 - d7 d0 - d7 d0 - d7 d0 - d7 d0 - d7 d0 - d7 d0 - d7 d8 - d15 ? d8 - d15 d8 - d15 d8 - d15 d8 - 15 d8 - 15 d16 - d23 ? ? ? d16 - d23 d16 - d23 d16 - d23 d24 - d31 ? ? ? d24 - d31 d24 - d31 d24 - d31 a0/nbs0 a0 ? nlb ? nlb (3) be0 (5) a1/nwr2/nbs2 a1 a0 a0 we (2) nlb (4) be2 (5) a2 - a22 a[2:22] a[1:21] a[1:21] a[0:20] a[0:20] a[0:20] a23 - a25 a[23:25] a[22:24] a[22:24] a[21:23] a[21:23] a[21:23] ncs0 cs cs cs cs cs cs ncs1/sdcs0 cs cs cs cs cs cs ncs2 cs cs cs cs cs cs ncs3/nandcs cs cs cs cs cs cs ncs4/cfcs0 cs cs cs cs cs cs ncs5/cfcs1 cs cs cs cs cs cs nrd/noe/cfoe oe oe oe oe oe oe nwr0/nwe we we (1) we we (2) we we nwr1/nbs1 ? we (1) nub we (2) nub (3) be1 (5) nwr3/nbs3 ? ? ? we (2) nub (4) be3 (5) sdsc1 ? ? ? ? ? cs
154 32015a?avr32?02/07 AT32AP7001 table 17-4. ebi pins and external devices connections signals pins of the interfaced device sdram compact flash compact flash true ide mode smart media or nand flash controller sdramc smc d0 - d7 d0 - d7 d0 - d7 d0 - d7 ad0-ad7 d8 - d15 d8 - d15 d8 - 15 d8 - 15 ad8-ad15 d16 - d31 d16 - d31 ? ? ? a0/nbs0 dqm0 a0 a0 ? a1/nwr2/nbs2 dqm2 a1 a1 ? a2 - a10 a[0:8] a[2:10] a[2:10] ? a11 a9 ? ? ? sda10 a10 ? ? ? a12 ? ? ? ? a13 - a14 a[11:12] ? ? ? a15 ? ? ? ? a16/ba0 ba0 ? ? ? a17/ba1 ba1 ? ? ? a18 - a20 ? ? ? ? a21 ? ? ? cle (3) a22 ? reg reg ale (3) a23 - a24 ? ? ? ? a25 ? ? ? ? ncs0 ? ? ? ? ncs1/sdcs0 cs[0] ? ? ? ncs2 ? ? ? ? ncs2/nandcs ? ? ? ? ncs3/nandcs ? ? ? ? ncs4/cfcs0 ? cfcs0 (1) cfcs0 (1) ? ncs5/cfcs1 ? cfcs1 (1) cfcs1 (1) ? nandoe ? ? ? oe nandwe ? ? ? we nrd/noe/cfoe ? oe ? ? nwr0/nwe/cfwe ? we we ? nwr1/nbs1/cfior dqm1 ior ior ? nwr3/nbs3/cfiow dqm3 iow iow ? cfrnw ? cfrnw (1) cfrnw (1) ? cfce1 ? ce1 cs0 ?
155 32015a?avr32?02/07 AT32AP7001 note: 1. not directly connected to t he compactflash slot. permits the co ntrol of the bidirectional buffer between the ebi data bus a nd the compactflash slot. 2. any pio line. 3. the cle and ale signals of the smartmedia device may be driven by any address bit. for details, see ?smartmedia and nand flash support? on page 162 . cfce2 ? ce2 cs1 ? sdck clk ? ? ? sdcke cke ? ? ? ras ras ? ? ? cas cas ? ? ? sdwe we ? ? ? nwait ? wait wait ? pxx (2) ? cd1 or cd2 cd1 or cd2 ? pxx (2) ???ce pxx (2) ???rdy sdcs1 cs[1] ? ? ? table 17-4. ebi pins and external devices connections (continued) signals pins of the interfaced device sdram compact flash compact flash true ide mode smart media or nand flash controller sdramc smc
156 32015a?avr32?02/07 AT32AP7001 17.5.2 connection examples figure 17-2 shows an example of connections be tween the ebi and external devices. figure 17-2. ebi connections to memory devices ebi d0-d31 a2-a15 ras cas sdck sdcke sdwe a0/nbs0 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 nwr1/nbs1 a1/nwr2/nbs2 nwr3/nbs3 ncs1/sdcs d0-d7 d8-d15 a16/ba0 a17/ba1 a18-a25 a10 sda10 sda10 a2-a11, a13 ncs0 ncs2 ncs3 ncs4 ncs5 a16/ba0 a17/ba1 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 a10 sda10 a2-a11, a13 a16/ba0 a17/ba1 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 d16-d23 d24-d31 a10 sda10 a2-a11, a13 a16/ba0 a17/ba1 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 a10 sda10 a2-a11, a13 a16/ba0 a17/ba1 nbs0 nbs1 nbs3 nbs2 nrd/noe nwr0/nwe 128k x 8 sram 128k x 8 sram d0-d7 d0-d7 a0-a16 a0-a16 a1-a17 a1-a17 cs cs oe we d0-d7 d8-d15 oe we nrd/noe a0/nwr0/nbs0 nrd/noe nwr1/nbs1 sdwe sdwe sdwe sdwe
157 32015a?avr32?02/07 AT32AP7001 17.6 product dependencies 17.6.1 i/o lines the pins used for interfacing the external bus interface may be multiplexed with the pio lines. the programmer must first program the pio controller to assign the external bus interface pins to their peripheral function. if i/o lines of the external bus interface are not used by the applica- tion, they can be used for other purposes by the pio controller. 17.7 functional description the ebi transfers data between the internal hsb bus (handled by the hmatrix) and the external memories or peripheral devices. it controls the waveforms and the parameters of the external address, data and control busses and is composed of the following elements: ? the static memory controller (smc) ? the sdram controller (sdramc) ? the ecc controller (ecc) ? a chip select assignment feature that assigns an hsb address space to the external devices ? a multiplex controller circuit that shares the pins between the different memory controllers ? programmable compactflash support logic ? programmable smartmedia and nand flash support logic 17.7.1 bus multiplexing the ebi offers a complete set of control signal s that share the 32-bit data lines, the address lines of up to 26 bits and the control signals through a multiplex logic operating in function of the memory area requests. multiplexing is specifically organized in or der to guarantee the maintenance of the address and output control lines at a stable state while no ex ternal access is being pe rformed. mult iplexing is also designed to respect the data float times defined in the memory controllers. furthermore, refresh cycles of the sdram are executed independently by the sdram controller without delaying the other external memory controller accesses. 17.7.2 pull-up control a specific hmatrix_sfr register in the matrix user interface permit enabling of on-chip pull-up resistors on the data bu s lines not multiplexed with the pio controller lines. for details on this register, refer to the peripherals section. the pull-up resistors are enabled after reset. setting the ebi_dbpuc bit disables the pull-up resistors on lines not muxed with pio. enabling the pull- up resistor on lines multiplexed with pio lines can be performed by programming the appropri- ate pio controller. 17.7.3 static memory controller for information on the static memory controller, refer to the static memory controller section. 17.7.4 sdram controller for information on the sdram contro ller, refer to the sdram section. 17.7.5 ecc controller for information on the ecc contro ller, refer to the ecc section.
158 32015a?avr32?02/07 AT32AP7001 17.7.6 compactflash support the external bus interface integrates circuitry that interfaces to compactflash devices. the compactflash logic is driven by the st atic memory controller (smc) on the ncs4 and/or ncs5 address space. programming the ebi_cs4 a and/or ebi_cs5a bits in a hmatrix_sfr register to the appropriate value enables this logic. for details on this register, refer to the peripherals section. access to an external compactflash device is then made by accessing the address space reserved to ncs4 and/or ncs5 (i.e., between 0x2000 0000 and 0x23ff ffff for ncs4 and between 0x0400 0000 and 0x07ff ffff for ncs5). all compactflash modes (attribute memory, common memory, i/o and true ide) are sup- ported but the signals _iois16 (i/o and true ide modes) and _ata sel (true ide mode) are not handled. 17.7.6.1 i/o mode, common memory mode, attribute memory mode and true ide mode within the ncs4 and/or ncs5 address space, the current transfer address is used to distinguish i/o mode, common memory mode, attribute memory mode and true ide mode. the different modes are accessed through a specific memory mapping as illustrated on figure 17-3 . a[23:21] bits of the transfer address are used to select the desired mode as described in table 17-5 on page 159 . figure 17-3. compactflash memory mapping note: the a22 pin is used to drive the reg signal of the compactflash device (except in true ide mode). cf address space attribute memory mode space common memory mode space i/o mode space true ide mode space true ide alternate mode space offset 0x00e0 0000 offset 0x00c0 0000 offset 0x0080 0000 offset 0x0040 0000 offset 0x0000 0000
159 32015a?avr32?02/07 AT32AP7001 17.7.6.2 cfce1 and cfce2 signals to cover all types of access, the smc must be al ternatively set to drive 8-bit data bus or 16-bit data bus. the odd byte access on the d[7:0] bus is only possible when the smc is configured to drive 8-bit memory devices on the corresponding ncs pin (ncs4 or ncs5). the chip select register (dbw field in the corresponding chip select register) of the ncs4 and/or ncs5 address space must be set as shown in table 17-6 to enable the required access type. nbs1 and nbs0 are the byte selection signals from smc and are available when the smc is set in byte select mode on the corresponding chip select. the cfce1 and cfce2 waveforms are identical to the corresponding ncsx waveform. for details on these waveforms and timings, refer to the static memory controller section. table 17-5. compactflash mode selection a[23:21] mode base address 000 attribute memory 010 common memory 100 i/o mode 110 true ide mode 111 alternate true ide mode table 17-6. cfce1 and cfce2 truth table mode cfce2 cfce1 dbw comment smc access mode attribute memory nbs1 nbs0 16 bits access to even byte on d[7:0] byte select common memory nbs1 nbs0 16bits access to even byte on d[7:0] access to odd byte on d[15:8] byte select 1 0 8 bits access to odd byte on d[7:0] i/o mode nbs1 nbs0 16 bits access to even byte on d[7:0] access to odd byte on d[15:8] byte select 1 0 8 bits access to odd byte on d[7:0] true ide mode task file 1 0 8 bits access to even byte on d[7:0] access to odd byte on d[7:0] data register 1 0 16 bits access to even byte on d[7:0] access to odd byte on d[15:8] byte select alternate true ide mode control register alternate status read 01 don?t care access to even byte on d[7:0] don?t care drive address 0 1 8 bits access to odd byte on d[7:0] standby mode or address space is not assigned to cf 11? ? ?
160 32015a?avr32?02/07 AT32AP7001 17.7.6.3 read/write signals in i/o mode and true ide mode, the compactflash logic drives the read and write command signals of the smc on cfior and cfiow signals, while the cfoe and cfwe signals are deac- tivated. likewise, in common memory mode and attribute memory mode, the smc signals are driven on the cfoe and cfwe signals, while the cfior and cfiow are deactivated. figure 17-4 on page 160 demonstrates a schematic representation of this logic. attribute memory mode, common memory mode and i/o mode are supported by setting the address setup and hold time on the ncs4 (and/or ncs5) chip select to the appropriate values. for details on these signal waveforms, please refer to the section: setup and hold cycles of the static memory controller section. figure 17-4. compactflash read/write control signals 17.7.6.4 multiplexing of compactflash signals on ebi pins table 17-8 on page 161 and table 17-9 on page 161 illustrate the multiple xing of the compact- flash logic signals with other ebi signals on the ebi pins. the ebi pins in table 17-8 are strictly dedicated to the compactflash interface as soon as the ebi_cs4a and/or ebi_cs5a field of a specific hmatrix_sfr register is set, see the peripherals section for details. these pins must not be used to drive any other memory devices. the ebi pins in table 17-9 on page 161 remain shared between all memory areas when the cor- responding compactflash interface is enabled (ebi_cs4a = 1 and/or ebi_cs5a = 1). table 17-7. compactflash mode selection mode base address cfoe cfwe cfior cfiow attribute memory common memory nrd_noe nwr0_nwe 1 1 i/o mode 1 1 nrd_noe nwr0_nwe true ide mode 0 1 nrd_noe nwr0_nwe smc nrd_noe nwr0_nwe a23 cfior cfiow cfoe cfwe 1 1 compactflash logic external bus interface 1 1 1 0 a22 1 0 1 0 1 0
161 32015a?avr32?02/07 AT32AP7001 17.7.6.5 application example figure 17-5 on page 162 illustrates an example of a comp actflash application. cfcs0 and cfrnw signals are not directly connected to the compactflash slot 0, but do control the direc- tion and the output enable of the buffers between the ebi and the compactflash device. the timing of the cfcs0 signal is identical to the ncs4 signal. moreover, the cfrnw signal remains valid throughout the transfer, as does the address bus. the compactflash _wait sig- nal is connected to the nwait input of the static memory controller. for details on these waveforms and timings, refer to the static memory controller section. table 17-8. dedicated compactflash interface multiplexing pins compactflash signals ebi signals cs4a = 1 cs5a = 1 cs4a = 0 cs5a = 0 ncs4/cfcs0 cfcs0 ncs4 ncs5/cfcs1 cfcs1 ncs5 table 17-9. shared compactflash interface mu ltiplexing pins access to compactflash device access to other ebi devices compactflash sign als ebi signals noe/nrd/cfoe cfoe nrd/noe nwr0/nwe/cfwe cfwe nwr0/nwe nwr1/nbs1/cfior cfior nwr1/nbs1 nwr3/nbs3/cfiow cfiow nwr3/nbs3 a25/cfrnw cfrnw a25
162 32015a?avr32?02/07 AT32AP7001 figure 17-5. compactflash application example 17.7.7 smartmedia and nand flash support the external bus interface integrates circuitry that interfaces to smartmedia and nand flash devices. the smartmedia logic is driven by the static memory controller on the ncs3 address space. programming the ebi_cs3a field in a specific hmatrix_sfr register to the appropriate value enables the smartmedia logic. for details on this register, refer to the peripherals section. access to an external smartmedia device is then made by accessing the address space reserved to ncs3 (i.e., between 0x0c00 0000 and 0x0fff ffff). the smartmedia logic drives the read and write command signals of the smc on the nandoe and nandwe signals when the ncs3 signal is active. nandoe and nandwe are invalidated as soon as the transfer address fails to lie in the ncs3 address space. see figure ?smartmedia signal multiplexing on ebi pins? on page 163 for more informations. fo r details on these wave- forms, refer to the static memory controller section. compactflash connecto r ebi d[15:0] /oe dir _cd1 _cd2 /oe d[15:0] a25/cfrnw ncs4/cfcs0 cd (pio) a[10:0] a22/reg noe/cfoe a[10:0] _reg _oe _we _iord _iowr _ce1 _ce2 nwe/cfwe nwr1/cfior nwr3/cfiow cfce1 cfce2 _wait nwait
163 32015a?avr32?02/07 AT32AP7001 figure 17-6. smartmedia signal mult iplexing on ebi pins 17.7.7.1 smartmedia signals the address latch enable and command latch enable signals on the smartmedia device are driven by address bits a22 and a21 of the ebi a ddress bus. the user should note that any bit on the ebi address bus can also be used for this purpose. the command, address or data words on the data bus of the smartmedia device are distinguished by using their address within the ncsx address space. the chip enable (ce) signal of the device and the ready/busy (r/b) sig- nals are connected to pio lines. the ce signal then remains asserted even when ncsx is not selected, preventing the device from returning to standby mode. smc nrd_noe nwr0_nwe nandoe nandwe smartmedia logic ncsx nandwe nandoe
164 32015a?avr32?02/07 AT32AP7001 figure 17-7. smartmedia application example note: the external bus interfaces is also able to support 16-bits devices. d[7:0] ale nandwe nandoe noe nwe a[22:21] cle ad[7:0] pio r/b ebi ce smartmedia pio ncsx/nandcs not connected
165 32015a?avr32?02/07 AT32AP7001 18. dma controller (dmac) rev: 2.06a.0 18.1 features ? 2 hsb master interfaces ? 3 channels ? software and hardware handshaking interfaces ? 11 hardware handshaking interfaces ? memory/non-memory periph erals to memory/non-mem ory peripherals transfer ? single-block dma transfer ? multi-block dma transfer ? linked lists ? auto-reloading ? contiguous blocks ? dma controller is always the flow controller ? additional features ? scatter and gather operations ? channel locking ? bus locking ? fifo mode ? pseudo fly-by operation 18.2 description the dma controller (dmac) is an hsb-central dma controller core that transfers data from a source peripheral to a destination peripheral over one or more system bus. one channel is required for each source/destination pair. in the most basic configuration, the dmac has one master interface and one channel. the master interface reads the data from a source and writes it to a destination. two system bus transfers are required for each dma data transfer. this is also known as a dual-access transfer. the dmac is programmed via the hsb slave interface.
166 32015a?avr32?02/07 AT32AP7001 18.3 block diagram figure 18-1. dma controller (dmac) block diagram 18.4 functional description 18.4.1 basic definitions source peripheral: device on a system bus layer from where the dmac reads data, which is then stored in the channel fifo. the source peripheral teams up with a destination peripheral to form a channel. destination peripheral: device to which the dmac writes the stored data from the fifo (previ- ously read from the source peripheral). memory: source or destination that is always ?ready? for a dma transfer and does not require a handshaking interface to interact with the dmac. a peripheral should be assigned as memory only if it does not insert more than 16 wait states. if more than 16 wait states are required, then the peripheral should use a handshaking interface (the default if the peripheral is not pro- grammed to be memory) in order to signal when it is ready to accept or supply data. channel: read/write datapath between a source peripheral on one configured system bus layer and a destination peripheral on the same or different system bus layer that occurs through the channel fifo. if the source peripheral is not memory, then a source handshaking interface is assigned to the channel. if the destination pe ripheral is not memory, then a destination hand- shaking interface is assigned to the channel. so urce and destination handshaking interfaces can be assigned dynamically by programming the channel registers. master interface: dmac is a master on the hsb bus reading data from the source and writing it to the destination over the hsb bus. slave interface: the hsb interface over which the dmac is programmed. the slave interface in practice could be on the same layer as any of the master interfaces or on a separate layer. handshaking interface: a set of signal registers that conform to a protocol and handshake between the dmac and source or destination peri pheral to control the transfer of a single or burst transaction between them. this interface is used to request, acknowledge, and control a hsb slave i/f hsb master i/f cfg interrupt generator fifo channel 0 src fsm dst fsm channel 1 dma controller irq_dma hsb slave hsb master
167 32015a?avr32?02/07 AT32AP7001 dmac transaction. a channel can receive a request through one of three types of handshaking interface: hardware, software, or peripheral interrupt. hardware handshaking interface: uses hardware signals to control the transfer of a single or burst transaction between the dmac and the source or destination peripheral. software handshaking interface: uses software registers to control the transfer of a single or burst transaction between the dmac and the source or destination peripheral. no special dmac handshaking signals are needed on the i/o of the peripheral. this mode is useful for interfacing an existing peripheral to the dmac without modifying it. peripheral interrupt handshaking interface: a simple use of the hardware handshaking inter- face. in this mode, the interrupt line from the peripheral is tied to the dma_req input of the hardware handshaking interface. other interface signals are ignored. flow controller: the device (either the dmac or source/destination peripheral) that determines the length of and terminates a dma block transfe r. if the length of a block is known before enabling the channel, then the dmac should be programmed as the flow controller. if the length of a block is not known prior to enabling the channel, the source or destination peripheral needs to terminate a block transfer. in this mode, the peripheral is the flow controller. flow control mode (cfgx.fcmode): special mode that only applies when the destination peripheral is the flow controller. it controls the pre-fetching of data from the source peripheral. transfer hierarchy: figure 18-2 on page 167 illustrates the hierarchy between dmac transfers, block transfers, transactions (single or burst), an d system bus transfers (single or burst) for non- memory peripherals. figure 18-3 on page 168 shows the transfer hierarchy for memory. figure 18-2. dmac transfer hierarchy for non-memory peripheral dmac transfer dma transfer level block block block block transfer level burst transaction burst transaction burst transaction single transaction dma transaction level burst transfer system bus burst transfer system bus burst transfer system bus single transfer system bus system bus transfer level single transfer system bus
168 32015a?avr32?02/07 AT32AP7001 figure 18-3. dmac transfer hierarchy for memory block: a block of dmac data. the amount of data (block length) is determined by the flow con- troller. for transfers between the dmac and memo ry, a block is broken directly into a sequence of system bus bursts and single transfers. for transfers between the dmac and a non-memory peripheral, a block is broken into a sequence of dmac transactions (single and bursts). these are in turn broken into a sequence of system bus transfers. transaction: a basic unit of a dmac transfer as determined by either the hardware or software handshaking interface. a transaction is only relevant for transfers between the dmac and a source or destination peripheral if the source or destination peripheral is a non-memory device. there are two types of transactions: single and burst. ? single transaction: the length of a single transaction is always 1 and is converted to a single system bus transfer. ? burst transaction: the length of a burst transaction is programmed into the dmac. the burst transaction is converted into a sequence of system bus bursts and single transfers. dmac executes each burst transfer by performing incremental bursts that are no longer than the maximum system bus burst size set. the burst transaction length is under program control and normally bears some relationship to the fifo sizes in the dmac and in the source and destination peripherals. dma transfer: software controls the number of blo cks in a dmac transfer. once the dma transfer has completed, then hardware within the dmac disables the channel and can generate an interrupt to signal the completion of the dma transfer. you can then re-program the channel for a new dma transfer. single-block dma transfer: consists of a single block. dmac transfer dma transfer level block block block block transfer level burst transfer system bus burst transfer system bus burst transfer system bus single transfer system bus system bus transfer level
169 32015a?avr32?02/07 AT32AP7001 multi-block dma transfer: a dma transfer may consist of mu ltiple dmac blocks. multi-block dma transfers are supported through block chaining (linked list pointers), auto-reloading of channel registers, and contiguous blocks. the source and destination can independently select which method to use. ? linked lists (block chaining) ? a linked list pointer (llp) points to the location in system memory where the next linked list item (lli) exists. the lli is a set of registers that describe the next block (block descriptor) and an llp register. the dmac fetches the lli at the beginning of every block when block chaining is enabled. ? auto-reloading ? the dmac automatically reloads the channel registers at the end of each block to the value when the channel was first enabled. ? contiguous blocks ? where the address between successive blocks is selected to be a continuation from the end of the previous block. scatter: relevant to destination transfers within a block. the destination system bus address is incremented/decremented by a programmed amount when a scatter boundary is reached. the number of system bus transfers between successive scatter boundaries is under software control. gather: relevant to source transfers within a block. the source system bus address is incre- mented/decremented by a programmed amount when a gather boundary is reached. the number of system bus transfers between successive gather boundaries is under software control. channel locking: software can program a channel to keep the hsb master interface by locking the arbitration for the master bus interface for the duration of a dma transfer, block, or transac- tion (single or burst). bus locking: software can program a channel to maintain control of the system bus bus by asserting hlock for the duration of a dma transfer, block, or transaction (single or burst). chan- nel locking is asserted for the duration of bus locking at a minimum. fifo mode: special mode to improve bandwidth. when enabled, the channel waits until the fifo is less than half full to fetch the data from the source peripheral and waits until the fifo is greater than or equal to half full to send data to the destination peripheral. thus, the channel can transfer the data using system bus bursts, eliminating the need to arbitrate for the hsb master interface for each single system bus transfer. when this mode is not enabled, the channel only waits until the fifo can transmit/accept a single system bus transfer before requesting the master bus interface. pseudo fly-by operation: typically, it takes two system bu s cycles to complete a transfer, one for reading the source and one for writing to the destination. however, when the source and des- tination peripherals of a dma transfer are on differ ent system bus layers, it is possible for the dmac to fetch data from the source and store it in the channel fifo at the same time as the dmac extracts data from the channel fifo and writes it to the destination peripheral. this activ- ity is known as pseudo fly-by operation . for this to occur, the master interface for both source and destination layers must win arbitration of their hsb layer. similarly, the source and destina- tion peripherals must win ownership of their respective master interfaces.
170 32015a?avr32?02/07 AT32AP7001 18.5 memory peripherals figure 18-3 on page 168 shows the dma transfer hierarchy of the dmac for a memory periph- eral. there is no handshaking interface with the dmac, and therefore the memory peripheral can never be a flow controller. once the channel is enabled, the transfer proceeds immediately without waiting for a transaction request. the alternative to not having a transaction-level hand- shaking interface is to allow the dmac to attempt system bus transfers to the peripheral once the channel is enabled. if the peripheral slave cannot accept these system bus transfers, it inserts wait states onto the bus until it is ready; it is not recommended that more than 16 wait states be inserted onto the bus. by using the handshaking interface, the peripheral can signal to the dmac that it is ready to transmit/receive data, and then the dmac can access the periph- eral without the peripheral inserting wait states onto the bus. 18.6 handshaking interface handshaking interfaces are used at the transactio n level to control the flow of single or burst transactions. the operation of the handshaking interface is different and depends on whether the peripheral or the dmac is the flow controller. the peripheral uses the handshaking interface to in dicate to the dmac that it is ready to trans- fer/accept data over the system bus. a non-memory peripheral can request a dma transfer through the dmac using one of two handshaking interfaces: ? hardware handshaking ? software handshaking software selects between the hardware or software handshaking interface on a per-channel basis. software handshaking is accomplished through memory-mapped registers, while hard- ware handshaking is accomplished usin g a dedicated handshaking interface. 18.6.1 software handshaking when the slave peripheral requires the dmac to perform a dma transaction, it communicates this request by sending an interrupt to the cpu or interrupt controller. the interrupt service routine then uses the software registers to initiate and control a dma trans- action. these software registers are used to implement the software handshaking interface. the hs_sel_src/hs_sel_dst bit in the cfgx channel configuration register must be set to enable software handshaking. when the peripheral is not the flow controller, then the last transaction registers lstsrcreg and lstdstreg are not used, and the values in these registers are ignored. 18.6.1.1 burst transactions writing a 1 to the reqsrcreg[x]/reqdstreg[x] register is always interpreted as a burst transac- tion request, where x is the channel number. however, in order for a burst transaction request to start, software must write a 1 to the sglreqsrcreg[x]/sglreqdstreg[x] register. you can write a 1 to the sglreqsrcreg[ x ]/sglreqdstreg[ x ] and reqsrcreg[ x ]/reqdstreg[ x ] registers in any order, but both registers must be asserted in order to initiate a burst transaction. upon completion of the burst transaction, the hardware clears the sglreqsrcreg[ x ]/sglreqd- streg[ x ] and reqsrcreg[ x ]/reqdstreg[ x ] registers.
171 32015a?avr32?02/07 AT32AP7001 18.6.1.2 single transactions writing a 1 to the sg lreqsrcreg/sglreqdstreg initiates a single transaction. upon completion of the single transaction, both the sglreq srcreg/sglreqdstreg and reqsrcreg/reqdstreg bits are cleared by hardware. therefore, writ ing a 1 to the reqsrcreg/reqdstreg is ignored while a single transaction has been initiated, and the requested burst transaction is not serviced. again, writing a 1 to the reqsrcreg/reqdstre g register is always a burst transaction request. however, in order for a burst transaction request to start, the corresponding channel bit in the sglreqsrcreg/sglreqdstreg must be asserted. therefore, to ensure that a burst transaction is serviced, you must write a 1 to the reqsrcr eg/reqdstreg before writing a 1 to the sglreqsr- creg/sglreqdstreg register. software can poll the relevant channel bit in the sglreqsrcreg/ sglreqdstreg and reqsr- creg/reqdstreg registers. when both are 0, then either the requested burst or single transaction has completed. alternatively, the intsrctran or intdsttran interrupts can be enabled and unmasked in order to generate an interrupt when the requested source or destination trans- action has completed. note: the transaction-complete interrupts are trigger ed when both single and burst transactions are complete. the same transaction-complete interrupt is used for both single and burst transactions. 18.6.2 hardware handshaking there are 11 hardware handshaking interfaces between the dmac and peripherals. refer to the ?peripherals? chapter for the device-s pecific mapping of these interfaces. 18.6.2.1 external dma request definition when an external slave peripheral requires the dmac to perform dma transactions, it communi- cates its request by asserting the external ndmareqx signal. this signal is resynchronized to ensure a proper functionality (see ?external dma request timing? on page 172 ). the external ndmareqx is asserted when the s ource threshold level is reached. after resyn- chronization, the rising edge of dma_req starts the transfer. dma_req is de-asserted when dma_ack is asserted. the external ndmareqx signal must be de-ass erted after the last transfer and re-asserted again before a new transaction starts. for a source fifo, an active edge is triggered on ndmareqx when the source fifo exceeds a watermark level. for a destination fifo, an active edge is triggered on ndmareqx when the destination fifo drops below the watermark level. the source transaction length, ctlx.src_msize, and destination transaction length, ctlx.dest_msize, must be set according to watermark levels on the source/destination peripherals.
172 32015a?avr32?02/07 AT32AP7001 figure 18-4. external dma request timing dma transfers dma transfers hclk ndmareqx dma_req dma_ack dma transfers dma transaction
173 32015a?avr32?02/07 AT32AP7001 18.7 dmac transfer types a dma transfer may consist of single or multi-block transfers. on successive blocks of a multi- block transfer, the sarx/darx register in the dm ac is reprogrammed using either of the follow- ing methods: ? block chaining using linked lists ? auto-reloading ? contiguous address between blocks on successive blocks of a multi-block transfer, the ctlx register in the dmac is re-programmed using either of the following methods: ? block chaining using linked lists ? auto-reloading when block chaining, using linked lists is the multi-block method of choice, and on successive blocks, the llpx register in the dmac is re-programmed using the following method: ? block chaining using linked lists a block descriptor (lli) consists of following registers, sarx , darx, llpx, ctl. these regis- ters, along with the cfgx register, are used by the dmac to set up and describe the block transfer. 18.7.1 multi-block transfers 18.7.1.1 block chaining using linked lists in this case, the dmac re-programs the channel registers prior to the start of each block by fetching the block descriptor for that block from system memory. this is known as an lli update. dmac block chaining is supported by using a linked list pointer register (llpx) that stores the address in memory of the next linked list item. each lli (block descriptor) contains the corre- sponding block descriptor (sarx, darx, llpx, ctlx). to set up block chaining, a sequence of linked lists must be programmed in memory. the sarx, darx, llpx and ctlx registers are fetched from system memory on an lli update. the updated contents of the ctlx register are written back to memory on block completion. fig- ure 18-5 on page 174 shows how to use chained linked lists in memory to define multi-block transfers using block chaining. the linked list multi-block transfers is initiated by programming llpx with llpx(0) (lli(0) base address) and ctlx with ctlx.llp_s_en and ctlx.llp_d_en.
174 32015a?avr32?02/07 AT32AP7001 figure 18-5. multi-block transfer using linked lists system memory sarx darx llpx(1) ctlx[31..0] ctlx[63..32] write back for sstatx write back for dstatx sarx darx llpx(2) ctlx[31..0] ctlx[63..32] write back for sstatx write back for dstatx llpx(0) llpx(2) llpx(1) lli(0) lli(1)
175 32015a?avr32?02/07 AT32AP7001 table 18-1. programming of transfer types and channel register update method (dmac state machine table) transfer type llp. loc = 0 llp_s_en ( ctlx) reload _sr ( cfgx) llp_d_en ( ctlx) reload_ ds ( cfgx) ctlx, llpx update method sarx update method darx update method write back 1) single block or last transfer of multi-block ye s 0 0 0 0 none, user reprograms none (single) none (single) no 2) autoreload multi-block transfer with contiguous sar ye s 0 0 0 1 ctlx,llpx are reloaded from initial values. contiguous auto- reload no 3) autoreload multi-block transfer with contiguous dar ye s 0 1 0 0 ctlx,llpx are reloaded from initial values. auto-reload con- tiguous no 4) autoreload multi-block transfer ye s 0 1 0 1 ctlx,llpx are reloaded from initial values. auto-reload auto- reload no 5) single block or last transfer of multi-block no 0 0 0 0 none, user reprograms none (single) none (single) ye s 6) linked list multi-block transfer with contiguous sar no 0 0 1 0 ctlx,llpx loaded from next linked list item contiguous linked list ye s 7) linked list multi-block transfer with auto-reload sar no 0 1 1 0 ctlx,llpx loaded from next linked list item auto-reload linked list ye s 8) linked list multi-block transfer with contiguous dar no 1 0 0 0 ctlx,llpx loaded from next linked list item linked list con- tiguous ye s 9) linked list multi-block transfer with auto-reload dar no 1 0 0 1 ctlx,llpx loaded from next linked list item linked list auto- reload ye s 10) linked list multi-block transfer no 1 0 1 0 ctlx,llpx loaded from next linked list item linked list linked list ye s
176 32015a?avr32?02/07 AT32AP7001 18.7.1.2 auto-reloading of channel registers during auto-reloading, the channel registers are reloaded with their initial values at the comple- tion of each block and the new values used for the new block. depending on the row number in table 18-1 on page 175 , some or all of the sarx, darx and ctlx channel registers are reloaded from their initial value at the start of a block transfer. 18.7.1.3 contiguous address between blocks in this case, the address between successive bloc ks is selected to be a continuation from the end of the previous block. enabling the source or destination address to be contiguous between blocks is a function of ctlx.llp_s_en, cfgx.reloa d_sr, ctlx.llp_d_en, and cfgx.reload_ds registers (see figure 18-1 on page 175 ). note: both sarx and darx updates cannot be se lected to be contiguous. if this functionality is required, the size of the block tr ansfer (ctlx.block_ts) must be increased. if this is at the max- imum value, use row 10 of table 18-1 on page 175 and setup the lli.sarx address of the block descriptor to be equal to the end sarx address of the previous block. similarly, setup the lli.darx address of the block descriptor to be equal to the end darx address of the previous block. 18.7.1.4 suspension of transfers between blocks at the end of every block transfer, an end of block interrupt is asserted if: ? interrupts are enabled, ctlx.int_en = 1 ? the channel block interrupt is unmasked, maskblock[n] = 0, where n is the channel number. note: the block complete interrupt is generated at the completion of the block transfer to the destination. for rows 6, 8, and 10 of table 18-1 on page 175 , the dma transfer does not stall between block transfers. for example, at the end of block n, the dmac automatically proceeds to block n + 1. for rows 2, 3, 4, 7, and 9 of table 18-1 on page 175 (sarx and/or darx auto-reloaded between block transfers), the dma transfer automatically stalls after the end of block. interrupt is asserted if the end of block interrupt is enabled and unmasked. the dmac does not proceed to the next block transfer until a write to the block interrupt clear register, clearblock[n], is performed by software. this clears the channel block complete interrupt. for rows 2, 3, 4, 7, and 9 of table 18-1 on page 175 (sarx and/or darx auto-reloaded between block transfers), the dma transfer does not stall if either: ? interrupts are disabled, ctlx.int_en = 0, or ? the channel block interrupt is masked, maskblock[n] = 1, where n is the channel number. channel suspension between blocks is used to ensu re that the end of block isr (interrupt ser- vice routine) of the next-to-last block is serviced before the start of the final block commences. this ensures that the isr has cleared the cfgx.reload_sr and/or cfgx.reload_ds bits before completion of the final block. the reload bits cfgx.reload_sr and/or cfgx.reload_ds should be cleared in the ?end of block isr? for the next-to-last block transfer. 18.7.2 ending multi-block transfers all multi-block transfers must end as shown in either row 1 or row 5 of table 18-1 on page 175 . at the end of every block transfer, the dmac samples the row number, and if the dmac is in
177 32015a?avr32?02/07 AT32AP7001 row 1 or row 5 state, then the previous block transferred was the last block and the dma trans- fer is terminated. note: row 1 and row 5 are used for single block transfers or terminating multiblock transfers. ending in row 5 state enables status fetch and writeback for the last block. ending in row 1 state disables status fetch and writeback for the last block. for rows 2,3 and 4 of table 18-1 on page 175 , (llpx = 0 and cfgx.reload_sr and/or cfgx.reload_ds is set), multi-block dma transfers continue until both the cfgx.reload_sr and cfgx.reload_ds registers are cleared by software. they should be programmed to zero in the end of block interrupt service routine that services the next-to-last block transfer. this puts the dmac into row 1 state. for rows 6, 8, and 10 (both cfgx.reload_sr and cfgx.reload_ds cleared) the user must setup the last block descriptor in memory such that both lli.ctlx.llp_s_en and lli.ctlx.llp_d_en are zero. if the lli.llpx register of the last block descriptor in memory is non-zero, then the dma transfer is terminated in row 5. if the lli.llpx register of the last block descriptor in memory is zero, then the dma transfer is terminated in row 1. for rows 7 and 9, the end-of-block interrupt serv ice routine that services the next-to-last block transfer should clear the cfgx.reload_sr and cfgx.reload_ds reload bits. the last block descriptor in memory should be set up so that both the lli.ctlx.llp_s_en and lli.ctlx.llp_d_en are zero. if the lli.llpx register of the last block descriptor in memory is non-zero, then the dma transfer is terminated in row 5. if the lli.llpx register of the last block descriptor in memory is zero, then the dma transfer is terminated in row 1. note: the only allowed transitions between the rows of table 18-1 on page 175 are from any row into row 1 or row 5. as already stated, a transition in to row 1 or row 5 is used to terminate the dma transfer. all other transitions between rows are not allowed. software must ensure that illegal tran- sitions between rows do not occur between blocks of a multi-block transfer. for example, if block n is in row 10 then the only allowed rows for block n + 1 are rows 10, 5 or 1. 18.8 programming a channel three registers, the llpx, the ctlx and cfgx, need to be programmed to set up whether single or multi-block transfers take place, and which type of multi-block transfer is used. the different transfer types are shown in table 18-1 on page 175 . the ?update method? column indicates where the values of sarx, darx, ctlx, and llpx are obtained for the next block transfer when multi-block dmac transfers are enabled. note: in table 18-1 on page 175 , all other combinations of ll px.loc = 0, ctlx.llp_s_en, cfgx.reload_sr, ctlx.llp_d_en, and cfgx.r eload_ds are illegal, and causes indeter- minate or erroneous behavior. 18.8.1 programming examples 18.8.1.1 single-block transfer (row 1) row 5 in table 18-1 on page 175 is also a single block transfer with writeback of control and sta- tus information enabled at the end of the single block transfer. 1. read the channel enable register to choose a free (disabled) channel. 2. clear any pending interrupts on the channel from the previous dma transfer by writing to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all interrupts have been cleared. 3. program the following channel registers:
178 32015a?avr32?02/07 AT32AP7001 a. write the starting source address in the sarx register for channel x. b. write the starting destination address in the darx register for channel x. c. program ctlx and cfgx according to row 1 as shown in table 18-1 on page 175 . program the llpx register with ?0?. d. write the control information for the dma transfer in the ctlx register for channel x. for example, in the register, you can program the following: ? i. set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the tt_fc of the ctlx register. ? ii. set up the transfer characteristics, such as: ? transfer width for the source in the src_tr_width field. ? transfer width for the destination in the dst_tr_width field. ? source master layer in the sms field where source resides. ? destination master layer in the dms field where destination resides. ? incrementing/decrementing or fixed address for source in sinc field. ? incrementing/decrementing or fixed address for destination in dinc field. e. write the channel configuration information into the cfgx register for channel x. ? i. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires programming the hs_sel_src/hs_sel_dst bits, respectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests. writing a ?1? activates the software handshaking interface to handle source/destination requests. ? ii. if the hardware handshaking interface is activated for the source or destination peripheral, assign a handshaking interface to the source and destination peripheral. this requires programming the src_per and dest_per bits, respectively. 4. after the dmac selected channel has been programmed, enable the channel by writing a ?1? to the chenreg.ch_en bit. make sure that bit 0 of the dmacfgreg register is enabled. 5. source and destination request single and burst dma transactions to transfer the block of data (assuming non-memory peripherals). the dmac acknowledges at the comple- tion of every transaction (burst and single) in the block and carry out the block transfer. 6. once the transfer completes, hardware sets the interrupts and disables the channel. at this time you can either respond to the block complete or transfer complete interrupts, or poll for the channel enable (chenreg.ch_en) bit until it is cleared by hardware, to detect when the transfer is complete. 18.8.1.2 multi-block transfer with linked list for source and linked list for destination (row 10) 1. read the channel enable register to choose a free (disabled) channel. 2. set up the chain of linked list items (otherwise known as block descriptors) in memory. write the control information in the lli.ctlx register location of the block descriptor for each lli in memory (see figure 18-5 on page 174 ) for channel x. for example, in the register, you can program the following: a. set up the transfer type (memory or non-memory peripheral for source and desti- nation) and flow control device by programming the tt_fc of the ctlx register. b. set up the transfer characteristics, such as: ? i. transfer width for the source in the src_tr_width field.
179 32015a?avr32?02/07 AT32AP7001 ? ii. transfer width for the destination in the dst_tr_width field. ? iii. source master layer in th e sms field where source resides. ? iv. destination master layer in the dms field where destination resides. ? v. incrementing/decrementing or fixed address for source in sinc field. ? vi. incrementing/decrementing or fixed address for destination dinc field. 3. write the channel configuration information into the cfgx register for channel x. a. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires pro- gramming the hs_sel_src/hs_sel_dst bits, respectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests for the specific channel. writing a ?1? activates the software handshaking interface to handle source/destination requests. b. if the hardware handshaking interface is activated for the source or destination peripheral, assign the handshaking interface to the source and destination periph- eral. this requires programming the src_per and dest_per bits, respectively. 4. make sure that the lli.ctlx register locations of all lli entries in memory (except the last) are set as shown in row 10 of table 18-1 on page 175 . the lli.ctlx register of the last linked list item must be set as described in row 1 or row 5 of table 18-1 . fig- ure 18-7 on page 181 shows a linked list example with two list items. 5. make sure that the lli.llpx register locations of all lli entries in memory (except the last) are non-zero and point to the base address of the next linked list item. 6. make sure that the lli.sarx/lli.darx register locations of all lli entries in memory point to the start source/destination block address preceding that lli fetch. 7. make sure that the lli.ctlx.done field of the lli.ctlx register locations of all lli entries in memory are cleared. 8. clear any pending interrupts on the channel from the previous dma transfer by writing to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all interrupts have been cleared. 9. program the ctlx, cfgx registers according to row 10 as shown in table 18-1 on page 175 . 10. program the llpx register with llpx(0), the pointer to the first linked list item. 11. finally, enable the channel by writing a ?1? to the chenreg.ch_en bit. the transfer is performed. 12. the dmac fetches the first lli from the location pointed to by llpx(0). note: the lli.sarx, lli. darx, lli.llpx and lli.ct lx registers are fetched. the dmac automatically reprograms the sarx, darx, llpx and ctlx channel registers from the llpx(0). 13. source and destination request single and burst dma transactions to transfer the block of data (assuming non-memory peripheral). the dmac acknowledges at the comple- tion of every transaction (burst and single) in the block and carry out the block transfer. 14. the ctlxh register is written out to system memory. for conditions under which the ctlxh register is written out to system memory, refer to ?writeback? column of table 18-1 on page 175 . the ctlxh register is written out to the same location on the same layer (llpx.lms) where it was originally fetc hed; that is, the location of the ctlx regis- ter of the linked list item fetched prior to the start of the block transfer. only the second word of the ctlx register is written out, ctlxh, because only the ctlx.block_ts and ctlx.done fields have been updated by dmac hardware. additionally, the ctlx.done bit is asserted to indicate block completion. therefore, software can poll
180 32015a?avr32?02/07 AT32AP7001 the lli.ctlx.done bit of the ctlx register in the lli to ascertain when a block trans- fer has completed. note: do not poll the ctlx.done bit in the dmac memo ry map. instead, poll the lli.ctlx.done bit in the lli for that block. if the polled lli.ctlx.done bit is asserted, then this block transfer has completed. this lli.ctlx.done bit was cleared at the start of the transfer (step 7). 15. the dmac does not wait for the block interrupt to be cleared, but continues fetching the next lli from the memory location pointed to by current llpx register and automatically reprograms the sarx, darx, llpx and ctlx channel registers. the dma transfer con- tinues until the dmac determines that the ctlx and llpx registers at the end of a block transfer match that described in row 1 or row 5 of table 18-1 on page 175 . the dmac then knows that the previous block transferred was the last block in the dma transfer. the dma transfer might look like that shown in figure 18-6 on page 180 . figure 18-6. multi-block with linked list address for source and destination if the user needs to execute a dma transfer wh ere the source and destination address are con- tiguous but the amount of data to be transferred is greater than the maximum block size ctlx.block_ts, then this can be achieved usin g the type of multi-block transfer as shown in figure 18-7 on page 181 . sar(2) sar(1) sar(0) dar(2) dar(1) dar(0) block 2 block 1 block 0 block 0 block 1 block 2 address of source layer address of destination layer source blocks destination blocks
181 32015a?avr32?02/07 AT32AP7001 figure 18-7. multi-block with linked address for source and destination blocks are contiguous the dma transfer flow is shown in figure 18-8 on page 182 . sar(2) sar(1) sar(0) dar(2) dar(1) dar(0) block 2 block 1 block 0 block 0 block 1 block 2 address of source layer address of destination layer source blocks destination blocks sar(3) block 2 dar(3) block 2
182 32015a?avr32?02/07 AT32AP7001 figure 18-8. dma transfer flow for source and destination linked list address channel enabled by software lli fetch hardware reprograms sarx, darx, ctlx, llpx dmac block transfer source/destination status fetch writeback of control and source/destination status of lli is dmac in row1 or row5 of dmac state machine table? channel disabled by hardware block complete interrupt generated here dmac transfer complete interrupt generated here yes no
183 32015a?avr32?02/07 AT32AP7001 18.8.1.3 dma transfer flow for source and destination linked list address multi-block transfer with source address auto-reloaded and destination address auto-reloaded (row 4) 1. read the channel enable register to choose an available (disabled) channel. 2. clear any pending interrupts on the channel from the previous dma transfer by writing to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all interrupts have been cleared. 3. program the following channel registers: a. write the starting source address in the sarx register for channel x. b. write the starting destination address in the darx register for channel x. c. program ctlx and cfgx according to row 4 as shown in table 18-1 on page 175 . program the llpx register with ?0?. d. write the control information for the dma transfer in the ctlx register for channel x. for example, in the register, you can program the following: ? i. set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the tt_fc of the ctlx register. ? ii. set up the transfer characteristics, such as: ? transfer width for the source in the src_tr_width field. ? transfer width for the destination in the dst_tr_width field. ? source master layer in the sms field where source resides. ? destination master layer in the dms field where destination resides. ? incrementing/decrementing or fixed address for source in sinc field. ? incrementing/decrementing or fixed address for destination in dinc field. e. write the channel configuration information into the cfgx register for channel x. ensure that the reload bits, cfgx. reload_sr and cfgx.reload_ds are enabled. ? i. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires programming the hs_sel_src/hs_sel_dst bits, respectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests for the specific channel. writing a ?1? activates the software handshaking interface to handle source/destination requests. ? ii. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripheral. this requires programming the src_per and dest_per bits, respectively. 4. after the dmac selected channel has been programmed, enable the channel by writing a ?1? to the chenreg.ch_en bit. make sure that bit 0 of the dmacfgreg register is enabled. 5. source and destination request single and burst dmac transactions to transfer the block of data (assuming non-memory peripherals). the dmac acknowledges on com- pletion of each burst/single transaction and carry out the block transfer. 6. when the block transfer has completed, the dmac reloads the sarx, darx and ctlx registers. hardware sets the block comple te interrupt. the dmac then samples the row number as shown in table 18-1 on page 175 . if the dmac is in row 1, then the dma transfer has completed. hardware sets the transfer complete interrupt and dis- ables the channel. so you can either respond to the block complete or transfer
184 32015a?avr32?02/07 AT32AP7001 complete interrupts, or poll for the channel enable (chenreg.ch_en) bit until it is dis- abled, to detect when the transfer is complete. if the dmac is not in row 1, the next step is performed. 7. the dma transfer proceeds as follows: a. if interrupts are enabled (ctlx.int_en = 1) and the block complete interrupt is un- masked (maskblock[x] = 1?b1, where x is the channel number) hardware sets the block complete interrupt when the block transfer has completed. it then stalls until the block complete interrupt is cleared by software. if the next block is to be the last block in the dma transfer, then the block complete isr (interrupt service routine) should clear the reload bits in the cfgx.reload_sr and cfgx.reload_ds registers. this put the dmac into row 1 as shown in table 18-1 on page 175 . if the next block is not the last block in the dma transfer, then the reload bits should remain enabled to keep the dmac in row 4. b. if interrupts are disabled (ctlx.int_en = 0) or the block complete interrupt is masked (maskblock[x] = 1?b0, where x is the channel number), then hardware does not stall until it detects a write to the block complete interrupt clear register but starts the next block transfer immediately. in this case software must clear the reload bits in the cfgx.reload_sr and cfgx.reload_ds registers to put the dmac into row 1 of table 18-1 on page 175 before the last block of the dma transfer has completed. the transfer is similar to that shown in figure 18-9 on page 184 . the dma transfer flow is shown in figure 18-10 on page 185 . figure 18-9. multi-block dma transfer with source and destination address auto-reloaded address of source layer address of destination layer source blocks destination blocks blockn block2 block1 block0 sar dar
185 32015a?avr32?02/07 AT32AP7001 figure 18-10. dma transfer flow for source and destination address auto-reloaded 18.8.1.4 multi-block transfer with source address auto-reloaded and linked list destination address (row7) 1. read the channel enable register to choose a free (disabled) channel. 2. set up the chain of linked list items (otherwise known as block descriptors) in memory. write the control information in the lli.ctlx register location of the block descriptor for each lli in memory for channel x. for example, in the register you can program the following: a. set up the transfer type (memory or non-memory peripheral for source and desti- nation) and flow control peripheral by programming the tt_fc of the ctlx register. b. set up the transfer characteristics, such as: ? i. transfer width for the source in the src_tr_width field. ? ii. transfer width for the destination in the dst_tr_width field. ? iii. source master layer in th e sms field where source resides. ? iv. destination master layer in the dms field where destination resides. ? v. incrementing/decrementing or fixed address for source in sinc field. ? vi. incrementing/decrementing or fixed address for destination dinc field. channel enabled by software block transfer reload sarx, darx, ctlx channel disabled by hardware block complete interrupt generated here dmac transfer complete interrupt generated here yes no yes stall until block complete interrupt cleared by software ctlx.int_en=1 && maskblock[x]=1? no is dmac in row1 of dmac state machine table?
186 32015a?avr32?02/07 AT32AP7001 3. write the starting source address in the sarx register for channel x. note: the values in the lli.sarx register locations of each of the linked list items (llis) setup up in memory, although fetched during a lli fetch, are not used. 4. write the channel configuration information into the cfgx register for channel x. a. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires pro- gramming the hs_sel_src/hs_sel_dst bits, respectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests for the specific channel. writing a ?1? activates the software handshaking interface source/destination requests. b. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripheral. this requires programming the src_per and dest_per bits, respectively. 5. make sure that the lli.ctlx register locations of all llis in memory (except the last) are set as shown in row 7 of table 18-1 on page 175 while the lli.ctlx register of the last linked list item must be set as described in row 1 or row 5 of table 18-1 . figure 18-5 on page 174 shows a linked list example with two list items. 6. make sure that the lli.llpx register locations of all llis in memory (except the last) are non-zero and point to the next linked list item. 7. make sure that the lli.darx register location of all llis in memory point to the start destination block address proceeding that lli fetch. 8. make sure that the lli.ctlx.done field of the lli.ctlx register locations of all llis in memory is cleared. 9. clear any pending interrupts on the channel from the previous dma transfer by writing to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all interrupts have been cleared. 10. program the ctlx, cfgx registers according to row 7 as shown in table 18-1 on page 175 . 11. program the llpx register with llpx(0), the pointer to the first linked list item. 12. finally, enable the channel by writing a ?1? to the chenreg.ch_en bit. the transfer is performed. make sure that bit 0 of the dmacfgreg register is enabled. 13. the dmac fetches the first lli from the location pointed to by llpx(0). note: the lli.sarx, lli.darx, lli. llpx and lli.ct lx registers are fetched. the lli.sarx register although fetched is not used. 14. source and destination request single and burst dmac transactions to transfer the block of data (assuming non-memory peripherals). dmac acknowledges at the com- pletion of every transaction (burst and single) in the block and carry out the block transfer. 15. the ctlxh register is written out to system memory. for conditions under which the ctlxh register is written out to system memory, refer to ?writeback? column of table 18-1 on page 175 . the ctlxh register is written out to the same location on the same layer (llpx.lms) where it was originally fetched, that is the location of the ctlx regis- ter of the linked list item fetched prior to the start of the block transfer. only the second word of the ctlx register is written out, ctlxh, because only the ctlx.block_ts and ctlx.done fields have been updated by hardware within the dmac. the lli.ctlx.done bit is asserted to indicate block completion. therefore, software can
187 32015a?avr32?02/07 AT32AP7001 poll the lli.ctlx.done bit field of the ctlx register in the lli to ascertain when a block transfer has completed. note: do not poll the ctlx.done bit in the dmac me mory map. instead poll the lli.ctlx.done bit in the lli for that block. if the polled lli.ctlx.done bit is asserted, then this block transfer has completed. this lli.ctlx.done bit was cleared at the start of the transfer (step 8). 16. the dmac reloads the sarx register from the initial value. hardware sets the block complete interrupt. the dmac samples the row number as shown in table 18-1 on page 175 . if the dmac is in row 1 or 5, then the dma transfer has completed. hard- ware sets the transfer complete interrupt and disables the channel. you can either respond to the block complete or transfer complete interrupts, or poll for the channel enable (chenreg.ch_en) bit until it is cleared by hardware, to detect when the trans- fer is complete. if the dmac is not in row 1 or 5 as shown in table 18-1 on page 175 the following steps are performed. 17. the dma transfer proceeds as follows: a. if interrupts are enabled (ctlx.int_en = 1) and the block complete interrupt is un- masked (maskblock[x] = 1?b1, where x is the channel number) hardware sets the block complete interrupt when the block transfer has completed. it then stalls until the block complete interrupt is cleared by software. if the next block is to be the last block in the dma transfer, then the block complete isr (interrupt service routine) should clear the cfgx.reload_sr source reload bit. this puts the dmac into row1 as shown in table 18-1 on page 175 . if the next block is not the last block in the dma transfer, then the source reload bit should remain enabled to keep the dmac in row 7 as shown in table 18-1 on page 175 . b. if interrupts are disabled (ctlx.int_en = 0) or the block complete interrupt is masked (maskblock[x] = 1?b0, where x is the channel number) then hardware does not stall until it detects a write to the block complete interrupt clear register but starts the next block transfer immediately. in this case, software must clear the source reload bit, cfgx.reload_sr, to put the device into row 1 of table 18-1 on page 175 before the last block of the dma transfer has completed. 18. the dmac fetches the next lli from memory location pointed to by the current llpx register, and automatically reprograms the darx, ctlx and llpx channel registers. note that the sarx is not re-programmed as the reloaded value is used for the next dma block transfer. if the next block is the last block of the dma transfer then the ctlx and llpx registers just fetched from the lli should match row 1 or row 5 of table 18- 1 on page 175 . the dma transfer might look like that shown in figure 18-11 on page 188 .
188 32015a?avr32?02/07 AT32AP7001 figure 18-11. multi-block dma transfer with source address auto-reloaded and linked list destination address the dma transfer flow is shown in figure 18-12 on page 189 address of source layer address of destination laye r source blocks destination blocks sar block0 block1 block2 blockn dar(n) dar(1) dar(0) dar(2)
189 32015a?avr32?02/07 AT32AP7001 figure 18-12. dma transfer flow for source address auto-reloaded and linked list destina- tion address channel enabled by software lli fetch yes no no yes hardware reprograms darx, ctlx, llpx dmac block transfer source/destination status fetch writeback of control and source/destination status of lli reload sarx block complete interrupt generated here dmac transfer complete interrupt generated here channel disabled by hardware ctlx.int_en=1 && maskblock[x]=1 ? stall until block interrupt cleared by hardware is dmac in row1 or row5 of dmac state machine table?
190 32015a?avr32?02/07 AT32AP7001 18.8.1.5 multi-block transfer with source address auto-reloaded and contiguous destination address (row 3) 1. read the channel enable register to choose a free (disabled) channel. 2. clear any pending interrupts on the channel from the previous dma transfer by writing to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all interrupts have been cleared. 3. program the following channel registers: a. write the starting source address in the sarx register for channel x. b. write the starting destination address in the darx register for channel x. c. program ctlx and cfgx according to row 3 as shown in table 18-1 on page 175 . program the llpx register with ?0?. d. write the control information for the dma transfer in the ctlx register for channel x. for example, in this register, you can program the following: ? i. set up the transfer type (memory or non-memory peripheral for source and destination) and flow control device by programming the tt_fc of the ctlx register. ? ii. set up the transfer characteristics, such as: ? transfer width for the source in the src_tr_width field. ? transfer width for the destination in the dst_tr_width field. ? source master layer in the sms field where source resides. ? destination master layer in the dms field where destination resides. ? incrementing/decrementing or fixed address for source in sinc field. ? incrementing/decrementing or fixed address for destination in dinc field. e. write the channel configuration information into the cfgx register for channel x. ? i. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires programming the hs_sel_src/hs_sel_dst bits, respectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests for the specific channel. writing a ?1? activates the software handshaking interface to handle source/destination requests. ? ii. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripheral. this requires programming the src_per and dest_per bits, respectively. 4. after the dmac channel has been programmed, enable the channel by writing a ?1? to the chenreg.ch_en bit. make sure that bit 0 of the dmacfgreg register is enabled. 5. source and destination request single and burst dmac transactions to transfer the block of data (assuming non-memory peripherals). the dmac acknowledges at the completion of every transaction (burst and single) in the block and carries out the block transfer. 6. when the block transfer has completed, the dmac reloads the sarx register. the darx register remains unchanged. hardware sets the block complete interrupt. the dmac then samples the row number as shown in table 18-1 on page 175 . if the dmac is in row 1, then the dma transfer has completed. hardware sets the transfer complete interrupt and disables the channel. so you can either respond to the block complete or transfer complete interrupts, or poll for the channel enable (chenreg.ch_en) bit until it is cleared by hardware, to detect when the transfer is complete. if the dmac is not in row 1, the next step is performed.
191 32015a?avr32?02/07 AT32AP7001 7. the dma transfer proceeds as follows: a. if interrupts are enabled (ctlx.int_en = 1) and the block complete interrupt is un- masked (maskblock[x] = 1?b1, where x is the channel number) hardware sets the block complete interrupt when the block transfer has completed. it then stalls until the block complete interrupt is cleared by software. if the next block is to be the last block in the dma transfer, then the block complete isr (interrupt service routine) should clear the source reload bit, cfgx.reload_sr. this puts the dmac into row1 as shown in table 18-1 on page 175 . if the next block is not the last block in the dma transfer then the source reload bit should remain enabled to keep the dmac in row3 as shown in table 18-1 on page 175 . b. if interrupts are disabled (ctlx.int_en = 0) or the block complete interrupt is masked (maskblock[x] = 1?b0, where x is the channel number) then hardware does not stall until it detects a write to the block complete interrupt clear register but starts the next block transfer immediately. in this case software must clear the source reload bit, cfgx.reload_sr, to put the device into row 1 of table 18-1 on page 175 before the last block of the dma transfer has completed. the transfer is similar to that shown in figure 18-13 on page 191 . the dma transfer flow is shown in figure 18-14 on page 192 . figure 18-13. multi-block transfer with source address auto-reloaded and contiguous desti- nation address address of source layer address of destination layer source blocks destination blocks sar block0 block1 block2 dar(1) dar(0) dar(2)
192 32015a?avr32?02/07 AT32AP7001 figure 18-14. dma transfer for source address auto-reloaded and contiguous destination address 18.8.1.6 multi-block dma transfer with linked list for source and contiguous destination address (row 8) 1. read the channel enable register to choose a free (disabled) channel. 2. set up the linked list in memory. write the control information in the lli. ctlx register location of the block descriptor for each lli in memory for channel x. for example, in the register, you can program the following: a. set up the transfer type (memory or non-memory peripheral for source and desti- nation) and flow control device by programming the tt_fc of the ctlx register. b. set up the transfer characteristics, such as: ? i. transfer width for the source in the src_tr_width field. ? ii. transfer width for the destination in the dst_tr_width field. ? iii. source master layer in th e sms field where source resides. ? iv. destination master layer in the dms field where destination resides. channel enabled by software block transfer reload sarx, ctlx channel disabled by hardware block complete interrupt generated here dmac transfer complete interrupt generated here yes no no yes stall until block complete interrupt cleared by software ctlx.int_en=1 && maskblock[x]=1? is dmac in row1 of dmac state machine table?
193 32015a?avr32?02/07 AT32AP7001 ? v. incrementing/decrementing or fixed address for source in sinc field. ? vi. incrementing/decrementing or fixed address for destination dinc field. 3. write the starting destination address in the darx register for channel x. note: the values in the lli.darx register location of each linked list item (lli) in memory, although fetched during an lli fetch, are not used. 4. write the channel configuration information into the cfgx register for channel x. a. designate the handshaking interface type (hardware or software) for the source and destination peripherals. this is not required for memory. this step requires pro- gramming the hs_sel_src/hs_sel_dst bits, respectively. writing a ?0? activates the hardware handshaking interface to handle source/destination requests for the specific channel. writing a ?1? activates the software handshaking interface to handle source/destination requests. b. if the hardware handshaking interface is activated for the source or destination peripheral, assign handshaking interface to the source and destination peripherals. this requires programming the src_per and dest_per bits, respectively. 5. make sure that all lli.ctlx register locations of the lli (except the last) are set as shown in row 8 of table 18-1 on page 175 , while the lli.ctlx register of the last linked list item must be set as described in row 1 or row 5 of table 18-1 . figure 18-5 on page 174 shows a linked list example with two list items. 6. make sure that the lli.llpx register locations of all llis in memory (except the last) are non-zero and point to the next linked list item. 7. make sure that the lli.sarx register location of all llis in memory point to the start source block address proceeding that lli fetch. 8. make sure that the lli.ctlx.done field of the lli.ctlx register locations of all llis in memory is cleared. 9. clear any pending interrupts on the channel from the previous dma transfer by writing to the interrupt clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. reading the interrupt raw status and interrupt status registers confirms that all interrupts have been cleared. 10. program the ctlx, cfgx registers according to row 8 as shown in table 18-1 on page 175 11. program the llpx register with llpx(0), the pointer to the first linked list item. 12. finally, enable the channel by writing a ?1? to the chenreg.ch_en bit. the transfer is performed. make sure that bit 0 of the dmacfgreg register is enabled. 13. the dmac fetches the first lli from the location pointed to by llpx(0). note: the lli.sarx, lli.darx, lli.llpx and lli.ct lx registers are fetched . the lli.darx register location of the lli although fetched is not us ed. the darx register in the dmac remains unchanged. 14. source and destination requests single and burst dmac transactions to transfer the block of data (assuming non-memory peripherals). the dmac acknowledges at the completion of every transaction (burst and single) in the block and carry out the block transfer. 15. the ctlxh register is written out to system memory. for conditions under which the ctlxh register is written out to system memory, refer to ?writeback? column of table 18-1 on page 175 . the ctlxh register is written out to the same location on the same layer (llpx.lms) where it was originally fetched, that is the location of the ctlx regis- ter of the linked list item fetched prior to the start of the block transfer. only the second word of the ctlx register is written out, ctlxh, because only the ctlx.block_ts and ctlx.done fields have been updated by hardware within the dmac. additionally,
194 32015a?avr32?02/07 AT32AP7001 the ctlx.done bit is asserted to indicate block completion. therefore, software can poll the lli.ctlx.done bit field of the ctlx register in the lli to ascertain when a block transfer has completed. note: do not poll the ctlx.done bit in the dmac me mory map. instead poll the lli.ctlx.done bit in the lli for that block. if the polled lli.ctlx.done bit is asserted, then this block transfer has completed. this lli.ctlx.done bit was cleared at the start of the transfer (step 8). 16. the dmac does not wait for the block interrupt to be cleared, but continues and fetches the next lli from the memory location pointed to by current llpx register and automat- ically reprograms the sarx, ctlx and llpx channel registers. the darx register is left unchanged. the dma transfer continues until the dmac samples the ctlx and llpx registers at the end of a block transfer match that described in row 1 or row 5 of table 18-1 on page 175 . the dmac then knows that the previous block transferred was the last block in the dma transfer. the dmac transfer might look like that shown in figure 18-15 on page 194 note that the desti- nation address is decrementing. figure 18-15. dma transfer with linked list source address and contiguous destination address the dma transfer flow is shown in figure 18-16 on page 195 . sar(2) sar(1) sar(0) dar(2) dar(1) dar(0) block 2 block 1 block 0 block 0 block 1 block 2 address of source layer address of destination laye r source blocks destination blocks
195 32015a?avr32?02/07 AT32AP7001 figure 18-16. dma transfer flow for source address auto-reloaded and contiguous destina- tion address channel enabled by software lli fetch hardware reprograms sarx, ctlx, llpx dmac block transfer source/destination status fetch writeback of control and source/destination status of lli is dmac in row 1 or row 5 of table 4 ? channel disabled by hardware block complete interrupt generated here dmac transfer complete interrupt generated here yes no
196 32015a?avr32?02/07 AT32AP7001 18.9 disabling a channel prio r to transfer completion under normal operation, software enables a channel by writing a ?1? to the channel enable reg- ister, chenreg.ch_en, and hardware disables a ch annel on transfer completion by clearing the chenreg.ch_en register bit. the recommended way for software to disable a channel without losing data is to use the ch_susp bit in conjunction with the fifo_empty bit in the channel configuration register (cfgx) register. 1. if software wishes to disable a channel prior to the dma transfer completion, then it can set the cfgx.ch_susp bit to tell the dmac to halt all transfers from the source peripheral. therefore, the channel fifo receives no new data. 2. software can now poll the cfgx.fifo_empty bit until it indicates that the channel fifo is empty. 3. the chenreg.ch_en bit can then be cleared by software once the channel fifo is empty. when ctlx.src_tr_width is less than ct lx.dst_tr_width and the cfgx.ch_susp bit is high, the cfgx.fifo_empty is asserted once the contents of the fifo do not permit a single word of ctlx.dst_tr_width to be formed. however, there may still be data in the channel fifo but not enough to form a single transfer of ctlx.dst_tr_width width. in this configura- tion, once the channel is disabled, the remaining data in the channel fifo are not transferred to the destination peripheral. it is permitted to remove the channel from the suspension state by writing a ?0? to the cfgx.ch_su sp register. the dma transfer completes in the normal manner. note: if a channel is disabled by software, an active single or burst transaction is not guaranteed to receive an acknowledgement. 18.9.1 abnormal transfer termination a dmac dma transfer may be terminated abruptly by software by clearing the channel enable bit, chenreg.ch_en. this does not mean that th e channel is disabled immediately after the chenreg.ch_en bit is cleared over the hsb slave interface. consider this as a request to dis- able the channel. the chenreg.ch_en must be polled and then it must be confirmed that the channel is disabled by reading back 0. a case where the channel is not be disabled after a chan- nel disable request is where either the source or destination has received a split or retry response. the dmac must keep re -attempting the transfer to th e system haddr that originally received the split or re try response until an okay response is returned. to do otherwise is an system bus protocol violation. software may terminate all channels abruptly by clearing the global enable bit in the dmac con- figuration register (dmacfgreg[0]). again, this does not mean that all channels are disabled immediately after the dmacfgreg[0] is cleared over the hsb slave interface. consider this as a request to disable all channels. the chenreg must be polled and then it must be confirmed that all channels are disabled by reading back ?0?. note: if the channel enable bit is cleared while there is data in the channel fifo, this data is not sent to the destination peripheral and is not present when the channel is re-enabled. for read sensitive source peripherals such as a sour ce fifo this data is therefor e lost. when the source is not a read sensitive device (i.e., memory), disabling a channel without waiting for the channel fifo to empty may be acceptable as the data is available from the source peripheral upon request and is not lost. note: if a channel is disabled by software, an active single or burst transaction is not guaranteed to receive an acknowledgement.
197 32015a?avr32?02/07 AT32AP7001 18.10 dma controller (d mac) user interface table 18-2. dma controller (dmac) user interface offset register register name access reset value 0x0 channel 0 source address register sar0 read/write 0x0 0x4 reserved - - - 0x8 channel 0 destination address register dar0 read/write 0x0 0xc reserved - - - 0x10 channel 0 linked list pointer register llp0 read/write 0x0 0x14 reserved - - - 0x18 channel 0 control register low ctl0l read/write - 0x1c channel 0 control register high ctl0h read/write - 0x20 reserved - - - 0x24 reserved - - - 0x28 reserved - - - 0x2c reserved - - - 0x30 reserved - - - 0x34 reserved - - - 0x38 reserved - - - 0x3c reserved - - - 0x40 channel 0 configuration register low cfg0l read/write 0x00000c00 0x44 channel 0 configuration register high cfg0h read/write 0x00000004 0x48 reserved - - - 0x4c reserved - - - 0x50 reserved - - - 0x54 reserved - - - 0x58 channel 1 source address register sar1 read/write 0x0 0x5c reserved - - - 0x60 channel 1 destination address register dar1 read/write 0x0 0x64 reserved - - - 0x68 channel 1 linked list pointer register llp1 read/write 0x0 0x7c reserved - - - 0x70 channel 1 control register low ctl1l read/write - 0x74 channel 1 control register high ctl1h read/write - 0x78 reserved - - - 0x7c reserved - - - 0x80 reserved - - - 0x84 reserved - - - 0x88 reserved - - -
198 32015a?avr32?02/07 AT32AP7001 0x8c reserved - - - 0x90 reserved - - - 0x94 reserved - - - 0x98 channel 1 configuration register low cfg1l read/write 0x00000c20 0x9c channel 1 configuration register high cfg1h read/write 0x00000004 0xa0 reserved - - - 0xa4 reserved - - - 0xa8 reserved - - - 0xac channel 2 source address register sar2 read/write 0x0 0xb0 reserved - - - 0xb4 channel 2 destination address register dar2 read/write 0x0 0xb8 reserved - - - 0xbc channel 2 linked list pointer register llp2 read/write 0x0 0xc0 reserved - - - 0xc4 channel 2 control register low ctl2l read/write - 0xc8 channel 2 control register high ctl2h read/write - 0xcc reserved - - - 0xd0 reserved - - - 0xd4 reserved - - - 0xd8 reserved - - - 0xdc reserved - - - 0xe0 reserved - - - 0xe4 reserved - - - 0xe8 reserved - - - 0xec channel 2 configuration register low cfg2l read/write 0x00000c00 0xf0 channel 2 configuration register high cfg2h read/write 0x00000004 0xf4 reserved - - - 0xf8 reserved - - - 0xfc reserved - - - 0x100..0x2b c reserved - - - 0x2c0 raw status for inttfr interrupt rawtfr read 0x0 0x2c4 reserved - - - 0x2c8 raw status for intblock interrupt rawblock read 0x0 0x2cc reserved - - - 0x2d0 raw status for intsrctran interrupt rawsrctran read 0x0 table 18-2. dma controller (dmac) user interface (continued) offset register register name access reset value
199 32015a?avr32?02/07 AT32AP7001 0x2d4 reserved - - - 0x2d8 raw status for intdsttran interrupt rawdsttran read 0x0 0x2dc reserved - - - 0x2e0 raw status for interr interrupt rawerr read 0x0 0x2e4 reserved - - - 0x2e8 status for inttfr interrupt statustfr read 0x0 0x2ec reserved - - - 0x2f0 status for intblock interrupt statusblock read 0x0 0x2f4 reserved - - - 0x2f8 status for intsrctran interrupt statussrctran read 0x0 0x2fc reserved - - - 0x300 status for intdsttran interrupt statusdsttran read 0x0 0x304 reserved - - - 0x308 status for interr interrupt statuserr read 0x0 0x30c reserved - - - 0x310 mask for inttfr interrupt masktfr read/write 0x0 0x314 reserved - - - 0x318 mask for intblock interrupt maskblock read/write 0x0 0x31c reserved - - - 0x320 mask for intsrctran interrupt masksrctran read/write 0x0 0x324 reserved - - - 0x328 mask for intdsttran interrupt maskdsttran read/write 0x0 0x32c reserved - - - 0x330 mask for interr interrupt maskerr read/write 0x0 0x334 reserved - - - 0x338 clear for inttfr interrupt cleartfr write 0x0 0x33c reserved - - - 0x340 clear for intblock interrupt clearblock write 0x0 0x344 reserved - - - 0x348 clear for intsrctran interrupt clearsrctran write 0x0 0x34c reserved - - - 0x350 clear for intdsttran interrupt cleardsttran write 0x0 0x354 reserved - - - 0x358 clear for interr interrupt clearerr write 0x0 0x35c reserved - - - 0x360 status for each interr upt type statusint read 0x0 table 18-2. dma controller (dmac) user interface (continued) offset register register name access reset value
200 32015a?avr32?02/07 AT32AP7001 0x364 reserved - - - 0x368 source software transaction re quest register reqsrcreg read/write 0x0 0x36c reserved - - - 0x370 destination software transaction request register reqdstreg read/write 0x0 0x374 reserved - - - 0x378 single source transaction request register sglreqsrcreg read/write 0x0 0x37c reserved - - - 0x380 single destination transaction req uest register sglreqdstreg read/write 0x0 0x384 reserved - - - 0x388 last source transaction req uest register lstsrcreg read/write 0x0 0x38c reserved - - - 0x390 last destination transaction r equest register lstdstreg read/write 0x0 0x394 reserved - - - 0x398 dma configuration register dmacfgreg read/write 0x0 0x39c reserved - - - 0x3a0 channel enable register chenreg read/write 0x0 0x3a4 reserved - - - 0x3a8 dma id register idreg read dma_id_num 0x3ac reserved - - - 0x3b0 dma test register dmatestreg read/write - 0x3b4 reserved - - - 0x3b8 reserved - - - 0x3b8 reserved - - - table 18-2. dma controller (dmac) user interface (continued) offset register register name access reset value
201 32015a?avr32?02/07 AT32AP7001 18.10.1 channel x source address register name: sarx access: read/write reset: 0x0 the address offset for each channel is: [x *0x58] for example, sar0: 0x000, sar1: 0x058, etc. ? sadd: source address of dma transfer the starting system bus source address is programmed by software before the dma channel is enabled or by a lli update before the start of the dma transfer. as the dma transfer is in progress, this register is updated to reflect the source address of the current system bus transfer. updated after each source system bus transfer. the sinc field in the ctlx register determines whether the address incre- ments, decrements, or is left unchanged on every source system bus transfer throughout the block transfer. 31 30 29 28 27 26 25 24 sadd 23 22 21 20 19 18 17 16 sadd 15 14 13 12 11 10 9 8 sadd 76543210 sadd
202 32015a?avr32?02/07 AT32AP7001 18.10.2 channel x destination address register name: darx access: read/write reset: 0x0 the address offset for each channel is: 0x08+[x * 0x58] for example, dar0: 0x008, dar1: 0x060, etc. ? dadd: destination addr ess of dma transfer the starting system bus destination address is programmed by software before the dma channel is enabled or by a lli update before the start of the dma transfer. as the dma transfer is in progress, this register is updated to reflect the desti- nation address of the current system bus transfer. updated after each destination system bus transfer. the dinc fi eld in the ctlx register determines whether the address increments, decrements or is left unchanged on every destination system bus transfer throughout the block transfer. 31 30 29 28 27 26 25 24 dadd 23 22 21 20 19 18 17 16 dadd 15 14 13 12 11 10 9 8 dadd 76543210 dadd
203 32015a?avr32?02/07 AT32AP7001 18.10.3 linked list pointer register for channel x name: llpx access: read/write reset: 0x0 the address offset for each channel is: 0x10+[x * 0x58] for example, llp0: 0x010, llp1: 0x068, etc. ? lms: list master select identifies the high speed bus interface for the device that stores the next linked list item. ? loc: address of the next lli starting address in memory of next lli if block chaining is enabled. the user need to program this register to point to the first linked list item (lli) in memory prior to enabling the channel if block chaining is enabled. the llp register has two functions: 1. the logical result of the equation llp.loc != 0 is used to set up the type of dma transfer (single or multi-block). if llp.loc is set to 0x0, then transfers using linked lists are not enabled. this register must be programmed prior to enabling the channel in order to set up the transfer type. it (llp.loc != 0) contains the pointer to the next linked listed item for block chaining using linked lists. 2. the llpx register is also used to point to the address where write back of the control and source/destination sta- tus information occurs after block completion. 31 30 29 28 27 26 25 24 loc 23 22 21 20 19 18 17 16 loc 15 14 13 12 11 10 9 8 loc 76543210 loc lms
204 32015a?avr32?02/07 AT32AP7001 18.10.4 control register for channel x low name: ctlxl access: read/write reset: 0x0 the address offset for each channel is: 0x18+[x * 0x58] for example, ctl0: 0x018, ctl1: 0x070, etc. this register contains fields that control the dma transfer. t he ctlxl register is part of the block descriptor (linked list it em) when block chaining is enabled. it can be varied on a block-by-block basis within a dma transfer when block chaining is enabled. ? int_en: interrupt enable bit if set, then all five interrupt generating sources are enabled. ? dst_tr_width: destination transfer width ? src_tr_width: source transfer width ? dinc: destination address increment indicates whether to increment or decrement the destination address on every destination system bus transfer. if your device is writing data to a destination peripheral fifo with a fixed address, then set this field to ?no change?. 00 = increment 01 = decrement 1x = no change ?sinc : source address increment indicates whether to increment or decrement the source addres s on every source system bus transfer. if your device is fetching data from a source peripheral fifo with a fixed address, then set this field to ?no change?. 00 = increment 01 = decrement 31 30 29 28 27 26 25 24 ? ? ? llp_s_en llp_d_en sms dms 23 22 21 20 19 18 17 16 dms tt_fc - - - src_msize 15 14 13 12 11 10 9 8 src_msize dest_msize sinc dinc 76543210 dinc src_tr_width dst_tr_width int_en src_tr_width/dst_tr_width size (bits) 000 8 001 16 010 32 other reserved
205 32015a?avr32?02/07 AT32AP7001 1x = no change ? dest_msize: destination burst transaction length number of data items, each of width ctlx.dst_tr_width , to be written to the destination every time a destination burst transaction request is made from either the corres ponding hardware or software handshaking interface. ?src_msize: source burst transaction length number of data items, each of width ctlx.src_tr_width , to be read from the source every time a source burst transac- tion request is made from either the correspondi ng hardware or software handshaking interface. ? tt_fc: transfer type and flow control the following transfer types are supported. ? memory to memory ? memory to peripheral ? peripheral to memory flow control can be assigned to the dmac, the so urce peripheral, or the destination peripheral. ?dms: destination master select identifies the master interface layer where the destination device (peripheral or memory) resides. 00 = hsb master 1 01 = reserved 10 = reserved 11 = reserved ?sms: source master select identifies the master interface layer where the source device (peripheral or memory) is accessed from. 00 = hsb master 1 01 = reserved 10 = reserved 11 = reserved ?llp_d_en block chaining is only enabled on the destination side if the llp_d_en field is high and llpx.loc is non-zero. tt_fc transfer type flow controller 000 memory to memory dmac 001 memory to peripheral dmac 010 peripheral to memory dmac 011 peripheral to peripheral dmac 100 peripheral to memory peripheral 101 peripheral to peripheral source peripheral 110 memory to peripheral peripheral 111 peripheral to peripheral destination peripheral
206 32015a?avr32?02/07 AT32AP7001 ?llp_s_en block chaining is only enabled on the source side if the llp_s_en field is high and llpx.loc is non-zero.
207 32015a?avr32?02/07 AT32AP7001 18.10.5 control register for channel x high name: ctlxh access: read/write reset: 0x0 ? block_ts: block transfer size when the dmac is flow controller, this fi eld is written by the user before the chan nel is enabled to indicate the block size. the number programmed into block_ts indicates the total number of single transactions to perform for every block transfer. the width of the single transaction is determined by ctlx.src_tr_width. ?done: done bit if status writeback is enabled, the control register ctlxh, is written to the control register location of the linked list item in system memory at the end of the block transfer with the done bit set. software can poll the lli ctlx.done bit to see when a bl ock transfer is complete. the lli ctlx.done bit should be cleared when the linked lists are setup in memory prior to enabling the channel. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 ? ? ? done block_ts 76543210 block_ts
208 32015a?avr32?02/07 AT32AP7001 18.10.6 configuration register for channel x low name: cfgxl access: read/write reset: 0x0 the address offset for each channel is: 0x40+[x * 0x58] for example, cfg0: 0x040, cfg1: 0x098, etc. ? ch_prior: channel priority a priority of 7 is the highest priority, and 0 is the lowest. this field must be programmed within the following range [0, x ? 1] a programmed value outside this range causes erroneous behavior. ? ch_susp: channel suspend suspends all dma data transfers from the source until this bit is cleared. there is no guarantee that the current transaction will complete. can also be used in conjunction with cf gx.fifo_empty to cleanly disable a channel without losing any data. 0 = not suspended. 1 = suspend. suspend dma transfer from the source. ? fifo_empty indicates if there is data left in the channel's fifo. can be used in conjunction with cfgx .ch_susp to cleanly disable a channel. 1 = channel's fifo empty 0 = channel's fifo not empty ? hs_sel_dst: destination software or hardware handshaking select this register selects which of the handshaking interfaces, hardware or software, is active for destination requests on this channel. 0 = hardware handshaking interface. software-initiated transaction requests are ignored. 1 = software handshaking interface. hardware initiated transaction requests are ignored. if the destination peripheral is memory, then this bit is ignored. ? hs_sel_src: source software or hardware handshaking select this register selects which of the handshaking interfaces, hardware or software, is active for source requests on this channel. 0 = hardware handshaking interface. software-initiated transaction requests are ignored. 31 30 29 28 27 26 25 24 reload_ds reload_sr max_abrst 23 22 21 20 19 18 17 16 max_abrst sr_hs_pol ds_hs_pol lock_b lock_ch 15 14 13 12 11 10 9 8 lock_b_l lock_ch_l hs_sel_sr hs_sel_ds fifo_empt ch_susp 76543210 ch_prior ?????
209 32015a?avr32?02/07 AT32AP7001 1 = software handshaking interface. hardware-initiated transaction requests are ignored. if the source peripheral is memory, then this bit is ignored. ?lock_ch_l : channel lock level indicates the duration over which cfgx.lock_ch bit applies. 00 = over complete dma transfer 01 = over complete dma block transfer 1x = over complete dma transaction ?lock_b_l: bus lock level indicates the duration over which cfgx.lock_b bit applies. 00 = over complete dma transfer 01 = over complete dma block transfer 1x = over complete dma transaction ?lock_ch: channel lock bit when the channel is granted control of the master bus interf ace and if the cfgx.lock_ch bit is asserted, then no other channels are granted control of the master bus interface for th e duration specified in cfgx.lock_ch_l. indicates to the master bus interface arbiter that this channel wants exclusive access to the master bus interface for the duration specified in cfgx.lock_ch_l. ?lock_b: bus lock bit when active, the system bus master signal hlock is asserted for the duration specified in cfgx.lock_b_l. ?ds_hs_pol: destination handshaking interface polarity 0 = active high 1 = active low ? sr_hs_pol: source handshaking interface polarity 0 = active high 1 = active low ? max_abrst: maximum system bus burst length maximum system bus burst length that is used for dma transfer s on this channel. a value of ?0? indicates that software is not limiting the maximum burst length for dma transfers on this channel. ? reload_sr: automatic source reload the sarx register can be automatically reloaded from its initial value at the end of every block for multi-block transfers. a new block transfer is then initiated. ? reload_ds: automatic destination reload the darx register can be automatically reloaded from its initial value at the end of every block for multi-block transfers. a new block transfer is then initiated.
210 32015a?avr32?02/07 AT32AP7001 18.10.7 configuration register for channel x high name: cfgxh access: read/write reset: 0x0 ?fcmode: flow control mode determines when source transaction requests are serviced when the destination peripheral is the flow controller. 0 = source transaction requests are serviced when they occur. data pre-fetching is enabled. 1 = source transaction requests are not serviced until a destinat ion transaction request occurs. in this mode the amount of data transferred from the source is limited such that it is guaranteed to be transferred to the destination prior to block term i- nation by the destination. data pre-fetching is disabled. ? fifo_mode: r/w 0x0 fifo mode select determines how much space or data needs to be available in the fifo before a burst transaction request is serviced. 0 = space/data available for single system bus transfer of the specified transfer width. 1 = space/data available is greater than or equal to half the fi fo depth for destination transfers and less than half the fifo depth for source transfers. the exceptions are at the end of a burst transaction request or at the end of a block transfer. ? protctl: protection control bits used to drive the system bus hprot[3:1] bus. the system bus specification recommends that the default value of hprot indicates a non-cached, nonbuffered, privileged data access. the reset value is used to indicate such an access. hprot[0] is tied high as all transfers are data accesses as there are no opcode fetches. there is a one-to-one mapping of these register bits to the hprot[3:1] master interface signals. ? src_per: source hardware handshaking interface assigns a hardware handshaking interface (0 - dmah_num_hs_int-1) to the source of channel x if the cfgx.hs_sel_src field is 0. otherwise, this field is ignored. the channel can then communicate with the source periph- eral connected to that interface via th e assigned hardware handshaking interface. for correct dmac operation, only one peripheral (source or destination) should be assi gned to the same handshaking interface. ? dest_per: destination hardware handshaking interface assigns a hardware handshaking interface (0 - dm ah_num_hs_int-1) to th e destination of channel x if the cfgx.hs_sel_dst field is 0. otherwise, this field is ignored. the channel can then communicate with the destination peripheral connected to that interface via the assigned hardware handshaking interface. for correct dma operation, only one peripheral (source or destination) should be assigned to the same handshaking interface. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ? dest_per src_per 76543210 src_per - - protctl fifo_mode fcmode
211 32015a?avr32?02/07 AT32AP7001 18.10.8 interrupt registers the following sections describe the registers pertaining to interrupts, their status, and how to clear them. for each channel, there are five types of interrupt sources: ? inttfr: dma transfer complete interrupt this interrupt is generated on dma transfer completion to the destination peripheral. ? intblock: block transfer complete interrupt this interrupt is generated on dma block transfer completion to the destination peripheral. ? intsrctran: source transaction complete interrupt this interrupt is generated after completion of the last sy stem bus transfer of the requested single/burst transaction from the handshaking interface on the source side. if the source for a channel is memory, then that channel never generates a intsrctran interrupt and hence the correspond- ing bit in this field is not set. ? intdsttran: destination transaction complete interrupt this interrupt is generated after completion of the last sy stem bus transfer of the requested single/burst transaction from the handshaking interface on the destination side. if the destination for a channel is memory, then that channel never generates the intdsttran interrupt and hence the corre- sponding bit in this field is not set. ? interr: error interrupt this interrupt is generated when an error response is received from an hsb slave on the hresp bus during a dma transfer. in addition, the dma transfer is cancelled and the channel is disabled.
212 32015a?avr32?02/07 AT32AP7001 18.10.9 interrupt raw status registers name: rawtfr, rawblock, rawsrc tran, rawdsttran, rawerr access: read reset: 0x0 the address offset are rawtfr ? 0x2c0 rawblock ? 0x2c8 rawsrctran ? 0x2d0 rawdsttran ? 0x2d8 rawerr ? 0x2e0 ? raw[2:0]: raw interrupt for each channel interrupt events are stored in these raw interrupt status registers before masking: rawtfr, rawblock, rawsrctran, rawdsttran, rawerr. each raw interrupt status register has a bit allocated per channel, for example, rawtfr[2] is chan- nel 2?s raw transfer complete interrupt. each bit in these regi sters is cleared by writing a 1 to the corresponding location in the cleartfr, clear block, clearsrctran, cleards ttran, clearerr registers. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?????raw2raw1raw0
213 32015a?avr32?02/07 AT32AP7001 18.10.10 interrupt status registers name: statustfr, statusblock, statussrctran, statusdsttran, statuserr access: read reset: 0x0 the address offset are statustfr: 0x2e8 statusblock: 0x2f0 statussrctran: 0x2f8 statusdsttran: 0x300 statuserr: 0x308 ? status[2:0] all interrupt events from all channels are stored in these interr upt status registers after masking: statustfr, statusblock, statussrctran, statusdsttran, statuserr. each interrupt status register has a bit allocated per channel, for example, sta- tustfr[2] is channel 2?s status transfer complete interrupt.the contents of these registers are used to generate the interrupt signals leaving the dmac. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?????status2status1status0
214 32015a?avr32?02/07 AT32AP7001 18.10.11 interrupt status registers name: masktfr, maskblock, masksrctran, maskdsttran, maskerr access: read/write reset: 0x0 the address offset are masktfr: 0x310 maskblock: 0x318 masksrctran: 0x320 maskdsttran: 0x328 maskerr: 0x330 the contents of the raw status registers are masked with the contents of the mask registers: masktfr, maskblock, masksrctran, maskdsttran, maskerr. each interrupt mask register has a bit allocated per channel, for example, mask- tfr[2] is the mask bit for channel 2?s transfer complete interrupt. a channel?s int_mask bit is only writt en if the corresponding mask write enable bit in the in t_mask_we field is asserted on the same system bus write transfer. this allows software to set a mask bit without performing a read-modified write operation. for example, writing hex 01x1 to the masktfr register writes a 1 into masktfr[0], while masktfr[7:1] remains unchanged. writing hex 00 xx leaves masktfr[7:0] unchanged. writing a 1 to any bit in these registers unmasks the corresponding interrupt, thus allowing the dmac to set the appropriate bit in the status registers. ? int_mask[2:0]: interrupt mask 0 = masked 1 = unmasked ? int_m_we[10:8]: interrupt mask write enable 0 = write disabled 1 = write enabled 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????int_m_we2int_m_we1int_m_we0 76543210 ?????int_m ask2 int_mask1 int_mask0
215 32015a?avr32?02/07 AT32AP7001 18.10.12 interrupt clear registers name: cleartfr, clearblock, clearsrctran, cleardsttran,clearerr access: write reset: 0x0 the address offset are cleartfr: 0x338 clearblock: 0x340 clearsrctran: 0x348 cleardsttran: 0x350 clearerr: 0x358 ? clear[2:0]: interrupt clear 0 = no effect 1 = clear interrupt each bit in the raw status and status registers is cleared on the same cycle by writing a 1 to the corresponding location in the clear registers: cleartfr, clearblock, clearsrctran, cleardsttran, clearerr. each interrupt clear register has a bit allo- cated per channel, for example, cleartfr[2] is the clear bit fo r channel 2?s transfer complete interrupt. writing a 0 has no effect. these registers are not readable. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?????clear2clear1clear0
216 32015a?avr32?02/07 AT32AP7001 18.10.13 combined interrupt status registers name: statusint access: read reset: 0x0 the contents of each of the five status registers (statustfr , statusblock, statussrctran, statusdsttran, statuserr) is or?d to produce a single bit per interrupt type in the combined status register (statusint). ?tfr or of the contents of statustfr register. ?block or of the contents of statusblock register. ?srct or of the contents of statussrctran register. ?dstt or of the contents of statusdsttran register. ?err or of the contents of statuserr register. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? err dstt srct block tfr
217 32015a?avr32?02/07 AT32AP7001 18.10.14 source software transaction request register name: reqsrcreg access: read/write reset: 0x0 a bit is assigned for each channel in this register. reqsrcreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel src_req bit is written only if the corresponding ch annel write enable bit in the req_we field is asserted on the same system bus write transfer. for example, writing 0x101 writes a 1 into reqsrcreg[0] , while reqsrcreg[3:1] remains unchanged. writing hex 0x0 yy leaves reqsrcreg[3:0] unchanged. this allows software to set a bit in the reqsrcreg register without performing a read- modified write ? src_req[2:0]: source request ? req_we[10:8]: request write enable 0 = write disabled 1 = write enabled 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????req_we2req_we1req_we0 76543210 ?????src_req2src_req1src_req0
218 32015a?avr32?02/07 AT32AP7001 18.10.15 destination software transaction request register name: reqdstreg access: read/write reset: 0x0 a bit is assigned for each channel in this register. reqdstreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel dst_req bit is written only if the corresponding channel write enable bit in the req_we field is asserted on the same system bus write transfer. ? dst_req[ 2:0]: destination request ? req_we[10:8]: request write enable 0 = write disabled 1 = write enabled 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????req_we2req_we1req_we0 76543210 ?????dst_req2dst_req1dst_req0
219 32015a?avr32?02/07 AT32AP7001 18.10.16 single source transaction request register name: sglreqsrcreg access: read/write reset: 0x0 a bit is assigned for each channel in this register. sglreqsrcreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel s_sg_req bit is written only if the corresponding channel write enable bit in th e req_we field is asserted on the same system bus write transfer. ? s_sg_req[2:0]: source single request ? req_we[10:8]: request write enable 0 = write disabled 1 = write enabled 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????req_we2req_we1req_we0 76543210 ?????s_sg_req2s_sg_req1s_sg_req0
220 32015a?avr32?02/07 AT32AP7001 18.10.17 single destination transaction request register name: sglreqdstreg access: read/write reset: 0x0 a bit is assigned for each channel in this register. sglreqdstreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel d_sg_req bit is written only if the corresponding channel write enable bit in the req_we field is asserted on the same system bus write transfer. ? d_sg_req[2:0]: destination single request ? req_we[10:8]: request write enable 0 = write disabled 1 = write enabled 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????req_we2req_we1req_we0 76543210 ?????d_sg_req2d_sg_req1d_sg_req0
221 32015a?avr32?02/07 AT32AP7001 18.10.18 last source transaction request register name: lstsrcreqreg access: read/write reset: 0x0 a bit is assigned for each channel in this register. lstsrcreqreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel lstsrc bit is written only if the corresponding c hannel write enable bit in the lstsr_we field is asserted on the same system bus write transfer. ? lstsrc[2:0]: source last transaction request ? lstsr_we[10 : 8]: source last transaction request write enable 0 = write disabled 1 = write enabled 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????lstsr_we2lstsr_we1lstsr_we0 76543210 ?????lstsrc2lstsrc1lstsrc0
222 32015a?avr32?02/07 AT32AP7001 18.10.19 last destination transaction request register name: lstdstreqreg access: read/write reset: 0x0 a bit is assigned for each channel in this register. lstdstreqreg[ n ] is ignored when software handshaking is not enabled for the source of channel n . a channel lstdst bit is written only if the corresponding ch annel write enable bit in the lstds_we field is asserted on the same system bus write transfer. ? lstdst[2:0]: destination last transaction request ? lstds_we[10:8]: destination last transaction request write enable 0 = write disabled 1 = write enabled 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????lstds_we2lstds_we1lstds_we0 76543210 ?????lstdst2lstdst1lstdst0
223 32015a?avr32?02/07 AT32AP7001 18.10.20 dmac configuration register name: dmacfgreg access: read/write reset: 0x0 ?dma_en: dma controller enable 0 = dmac disabled 1 = dmac enabled. this register is used to enable the dmac, which must be done before any channel activity can begin. if the global channel enable bit is clear ed while any channel is still active, then dm acfgreg.dma_en still returns ?1? to indi- cate that there are channels still active until hardware has terminated all activity on all channels, at which point the dmacfgreg.dma_en bit returns ?0?. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????dma_en
224 32015a?avr32?02/07 AT32AP7001 18.10.21 dmac channel enable register name: chenreg access: read/write reset: 0x0 ? ch_en[2:0] 0 = disable the channel 1 = enable the channel enables/disables the channel. setting this bit enables a channel, clearing this bit disables the channel. the chenreg.ch_en bit is automatically cleared by hardware to disable the channel after the last system bus transfer of the dma transfer to the destination has completed.software ca n therefore poll this bit to determine when a dma transfer has completed. ? ch_en_we[10:8] the channel enable bit, ch_en, is only written if the corresponding channel writ e enable bit, ch_en_we, is asserted on the same system bus write transfer. for example, writing 0x101 writes a 1 into chenreg[0], while chenreg[7:1] remains unchanged. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????ch_en_we2ch_en_we1ch_en_we0 76543210 ?????ch_en2ch_en1ch_en0
225 32015a?avr32?02/07 AT32AP7001 19. peripheral dma controller (pdc) rev: 6047c 19.1 features ? generates transfers to/from peripherals such as usart, ssc and spi ? supports up to 20 chan nels (product dependent) ? one master clock cycle needed for a transfer from memory to peripheral ? two master clock cycles needed for a transfer from peripheral to memory 19.2 description the peripheral dma controller (pdc) transfers data between on-chip serial peripherals such as the uart, usart, ssc, spi, and the on- and off-chip memories. using the peripheral dma controller avoids processor intervention and removes the processor interrupt-handling over- head. this significantly reduces the number of clock cycles required for a data transfer and, as a result, improves the performance of the microcontroller and makes it more power efficient. the pdc channels are implemented in pairs, each pair being dedicated to a particular periph- eral. one channel in the pair is dedicated to the receiving channel and one to the transmitting channel of each uart, usart, ssc and spi. the user interface of a pdc channel is integrated in the memory space of each peripheral. it contains: ? a 32-bit memory pointer register ? a 16-bit transfer count register ? a 32-bit register for next memory pointer ? a 16-bit register for next transfer count the peripheral triggers pdc transfers usin g transmit and receive signals. when the pro- grammed data is transferred, an end of trans fer interrupt is generated by the corresponding peripheral.
226 32015a?avr32?02/07 AT32AP7001 19.3 block diagram figure 19-1. block diagram control pdc channel 0 pdc channel 1 thr rhr control status & control peripheral peripheral dma controller memory controller
227 32015a?avr32?02/07 AT32AP7001 19.4 functional description 19.4.1 configuration the pdc channels user interface enables the user to configure and control the data transfers for each channel. the user interface of a pdc channel is integrated into the user interface of the peripheral (offset 0x100), which it is related to. per peripheral, it contains four 32-bit pointer registers (rpr, rnpr, tpr, and tnpr) and four 16-bit counter re gisters (rcr, rncr, tcr, and tncr). the size of the buffer (number of transfers) is configured in an internal 16-bit transfer counter register, and it is possible, at any moment, to read the number of transfers left for each channel. the memory base address is configured in a 32-bit memory pointer by defining the location of the first address to access in the memory. it is possible, at any moment, to read the location in memory of the next transfer and the number of remaining transfers. the pdc has dedicated sta- tus registers which indicate if the transfer is enabl ed or disabled for each channel. the status for each channel is located in the peripheral status register. transfers can be enabled and/or dis- abled by setting txten/txtdis and rxten/rxtd is in pdc transfer co ntrol register. these control bits enable reading the pointer and counter registers safely without any risk of their changing between both reads. the pdc sends status flags to the peripheral visible in its status-register (endrx, endtx, rxbuff, and txbufe). endrx flag is set when the periph_rcr register reaches zero. rxbuff flag is set when both pe riph_rcr and periph_rncr reach zero. endtx flag is set when the per iph_tcr register reaches zero. txbufe flag is set when both pe riph_tcr and periph_tncr reach zero. these status flags are described in the peripheral status register. 19.4.2 memory pointers each peripheral is connected to the pdc by a receiver data channel and a transmitter data channel. each channel has an internal 32-bit memory pointer. each memory pointer points to a location anywhere in the memory space (on-chip memory or external bus interface memory). depending on the type of transfer (byte, half-word or word), the memory pointer is incremented by 1, 2 or 4, respectively for peripheral transfers. if a memory pointer is reprogrammed while the pdc is in operation, the transfer address is changed, and the pdc performs transfers using the new address. 19.4.3 transfer counters there is one internal 16-bit transfer counter for each channel used to count the size of the block already transferred by its associated channel. these counters are decremented after each data transfer. when the counter reaches zero, the transfer is complete and the pdc stops transfer- ring data. if the next counter register is equal to zero, the pdc disables the trigger while activating the related peripheral end flag.
228 32015a?avr32?02/07 AT32AP7001 if the counter is reprogrammed while the pdc is operating, the number of transfers is updated and the pdc counts transfers from the new value. programming the next counter/pointer register s chains the buffers. the counters are decre- mented after each data transfer as stated above, but when the transfer counter reaches zero, the values of the next counter/pointer are loaded into the counter/pointer registers in order to re-enable the triggers. for each channel, two status bits indicate the end of the current buffer (endrx, entx) and the end of both current and next buffer (rxbuff, txbufe). these bits are directly mapped to the peripheral status register and can trigger an interrupt request to the interrupt controller. the peripheral end flag is automatically cleared when one of the counter-registers (counter or next counter regi ster) is written. note: when the next counter register is loaded into the counter register, it is set to zero. 19.4.4 data transfers the peripheral triggers pdc transfers using transmit (txrdy) and receive (rxrdy) signals. when the peripheral receives an external characte r, it sends a receive ready signal to the pdc which then requests access to the system bus. when access is granted, the pdc starts a read of the peripheral receive holding register (rhr) and then triggers a write in the memory. after each transfer, the relevant pdc memory pointer is incremented and the number of trans- fers left is decremented. when the memory bl ock size is reached, a signal is sent to the peripheral and the transfer stops. the same procedure is followed, in reverse, for transmit transfers. 19.4.5 priority of pdc transfer requests the peripheral dma controller handles transfer requests from the channel according to priori- ties fixed for each product.these prioriti es are defined in the product datasheet. if simultaneous requests of the same type (receiver or transmitter) occur on identical peripher- als, the priority is determined by the numbering of the peripherals. if transfer requests are not simultaneous, they are treated in the order they occurred. requests from the receivers are handled first and then followed by transmitter requests.
229 32015a?avr32?02/07 AT32AP7001 19.5 peripheral dma controll er (pdc) user interface note: 1. periph: ten registers are mapped in the peripheral memory space at the same offset. these can be defined by the user according to the function and the per ipheral desired (usart, ssc, spi, etc). table 19-1. register mapping offset register register name read/write reset 0x100 receive pointer register periph (1) _rpr read/write 0x0 0x104 receive counter register periph_rcr read/write 0x0 0x108 transmit pointer register periph_tpr read/write 0x0 0x10c transmit counter register periph_tcr read/write 0x0 0x110 receive next pointer register periph_rnpr read/write 0x0 0x114 receive next counter register periph_rncr read/write 0x0 0x118 transmit next pointer register periph_tnpr read/write 0x0 0x11c transmit next counter register periph_tncr read/write 0x0 0x120 pdc transfer control register periph_ptcr write-only - 0x124 pdc transfer status r egister periph_ptsr read-only 0x0
230 32015a?avr32?02/07 AT32AP7001 19.5.1 pdc receive pointer register register name: periph _ rpr access type: read/write ? rxptr: receive pointer address address of the next receive transfer. 31 30 29 28 27 26 25 24 rxptr 23 22 21 20 19 18 17 16 rxptr 15 14 13 12 11 10 9 8 rxptr 76543210 rxptr
231 32015a?avr32?02/07 AT32AP7001 19.5.2 pdc receive counter register register name: periph _ rcr access type: read/write ? rxctr: receive counter value number of receive transfers to be performed. 31 30 29 28 27 26 25 24 -- 23 22 21 20 19 18 17 16 -- 15 14 13 12 11 10 9 8 rxctr 76543210 rxctr
232 32015a?avr32?02/07 AT32AP7001 19.5.3 pdc transmit pointer register register name: periph _ tpr access type: read/write ? txptr: transmit pointer address address of the transmit buffer. 31 30 29 28 27 26 25 24 txptr 23 22 21 20 19 18 17 16 txptr 15 14 13 12 11 10 9 8 txptr 76543210 txptr
233 32015a?avr32?02/07 AT32AP7001 19.5.4 pdc transmit counter register register name: periph _ tcr access type: read/write ? txctr: transmit counter value txctr is the size of the transmit transfer to be performed. at zero, the peripheral data transfer is stopped. 31 30 29 28 27 26 25 24 -- 23 22 21 20 19 18 17 16 -- 15 14 13 12 11 10 9 8 txctr 76543210 txctr
234 32015a?avr32?02/07 AT32AP7001 19.5.5 pdc receive next pointer register register name: periph _ rnpr access type: read/write ? rxnptr: receive next pointer address rxnptr is the address of the next buffer to fill with received data when th e current buffer is full. 31 30 29 28 27 26 25 24 rxnptr 23 22 21 20 19 18 17 16 rxnptr 15 14 13 12 11 10 9 8 rxnptr 76543210 rxnptr
235 32015a?avr32?02/07 AT32AP7001 19.5.6 pdc receive next counter register register name: periph _ rncr access type: read/write ? rxncr: receive next counter value rxncr is the size of the next buffer to receive. 31 30 29 28 27 26 25 24 -- 23 22 21 20 19 18 17 16 -- 15 14 13 12 11 10 9 8 rxncr 76543210 rxncr
236 32015a?avr32?02/07 AT32AP7001 19.5.7 pdc transmit next pointer register register name: periph _ tnpr access type: read/write ? txnptr: transmit next pointer address txnptr is the address of the next buffer to transmit when the current buffer is empty. 31 30 29 28 27 26 25 24 txnptr 23 22 21 20 19 18 17 16 txnptr 15 14 13 12 11 10 9 8 txnptr 76543210 txnptr
237 32015a?avr32?02/07 AT32AP7001 19.5.8 pdc transmit next counter register register name: periph _ tncr access type: read/write ? txncr: transmit next counter value txncr is the size of the next buffer to transmit. 31 30 29 28 27 26 25 24 -- 23 22 21 20 19 18 17 16 -- 15 14 13 12 11 10 9 8 txncr 76543210 txncr
238 32015a?avr32?02/07 AT32AP7001 19.5.9 pdc transfer control register register name: periph_ptcr access type: write - only ? rxten: receiver transfer enable 0 = no effect. 1 = enables the receiver pdc transfer requests if rxtdis is not set. ? rxtdis: receiver transfer disable 0 = no effect. 1 = disables the receiver pdc transfer requests. ? txten: transmitter transfer enable 0 = no effect. 1 = enables the transmitter pdc transfer requests. ? txtdis: transmitter transfer disable 0 = no effect. 1 = disables the transmitter pdc transfer requests 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????txtdistxten 76543210 ??????rxtdisrxten
239 32015a?avr32?02/07 AT32AP7001 19.5.10 pdc transfer status register register name: periph _ ptsr access type: read-only ? rxten: receiver transfer enable 0 = receiver pdc transfer requests are disabled. 1 = receiver pdc transfer requests are enabled. ? txten: transmitter transfer enable 0 = transmitter pdc transfer requests are disabled. 1 = transmitter pdc transfer requests are enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????txten 76543210 ???????rxten
240 32015a?avr32?02/07 AT32AP7001 20. parallel input/outp ut controller (pio) rev: 2.0.2.0 20.1 features ? up to 32 programmable i/o lines ? fully programmable through set/clear registers ? multiplexing of two peripheral functions per i/o line ? for each i/o line (whether assigned to a peripheral or used as general purpose i/o) ? input change interrupt ? glitch filter ? programmable pull up on each i/o line ? pin data status register, supplies visibility of the le vel on the pin at any time ? synchronous output, provides set and clear of several i/o lines in a single write 20.2 description the parallel input/output controller (pio) manages up to 32 fully programmable input/output lines. each i/o line may be dedicated as a general-purpose i/o or be assigned to a function of an embedded peripheral. this assures effective optimization of the pins of a product. each i/o line is associated with a bit number in all of the 32-bit registers of the 32-bit wide user interface. each i/o line of the pio controller features: ? an input change interrupt enabling level change detection on any i/o line. ? a glitch filter providing rejection of pulses lower than one-half of clock cycle. ? control of the the pull-up of the i/o line. ? input visibility and output control. the pio controller also features a synchronous output providing up to 32 bits of data output in a single write operation.
241 32015a?avr32?02/07 AT32AP7001 20.3 block diagram figure 20-1. block diagram figure 20-2. application block diagram embedded peripheral embedded peripheral pio interrupt pio controller up to 32 pins power manager up to 32 peripheral ios up to 32 peripheral ios pio clock peripheral bus interrupt controller data, enable pin 31 pin 1 pin 0 data, enable on-chip peripherals pio controller on-chip peripheral drivers control & command driver keyboard driver keyboard driver general purpose i/os external devices
242 32015a?avr32?02/07 AT32AP7001 20.4 product dependencies 20.4.1 pin multiplexing each pin is configurable, according to product definition as either a general-purpose i/o line only, or as an i/o line multiplexed with one or two peripheral i/os. as the multiplexing is hard- ware-defined and thus product-dependent, the hardware designer and programmer must carefully determine the configuration of the pio controllers required by their application. when an i/o line is general-purpose only, i.e. not multiplexed with any peripheral i/o, programming of the pio controller regarding the assignment to a peripheral has no effect and only the pio con- troller can control how the pin is driven by the product. 20.4.2 external interrupt lines the external interrupt request signals are most generally multiplexed through the pio control- lers. however, it is not necessary to assign t he i/o line to the interrupt function as the pio controller has no effect on inputs and the external interrupt lines are used only as inputs. 20.4.3 power management the pio clock is generated by the power manager. before accessing the pio, the programmer must ensure that the pio clock is enabled in the power manager. note that the pio clock must be enabled when using the input change interrupt. in the pio description, master clock (mck) is th e clock of the peripheral bus to which the pio is connected. 20.4.4 interrupt generation the pio interrupt line is connected to the interr upt controller. using th e pio interrupt requires the interrupt controller to be programmed first.
243 32015a?avr32?02/07 AT32AP7001 20.5 functional description the pio controller features up to 32 fully-programmable i/o lines. most of the control logic asso- ciated to each i/o is represented in figure 20-3 . in this description each signal shown represents but one of up to 32 possible indexes. figure 20-3. i/o line control logic 1 0 1 0 glitch filter peripheral b input peripheral a input 1 0 pio_ifdr[0] pio_ifsr[0] pio_ifer[0] edge detector pio_pdsr[0] pio_isr[0] pio_idr[0] pio_imr[0] pio_ier[0] pio interrupt (up to 32 possible inputs) pio_isr[31] pio_idr[31] pio_imr[31] pio_ier[31] pad pio_pudr[0] pio_pusr[0] pio_puer[0] pio_codr[0] pio_odsr[0] pio_sodr[0] pio_pdr[0] pio_psr[0] pio_per[0] 1 0 1 0 pio_bsr[0] pio_absr[0] pio_asr[0] peripheral b output enable peripheral a output enable peripheral b output peripheral a output pio_odr[0] pio_osr[0] pio_oer[0]
244 32015a?avr32?02/07 AT32AP7001 20.5.1 pull-up resistor control each i/o line is designed with an embedded pull-up resistor. the pull-up resistor can be enabled or disabled by writing respectively puer (p ull-up enable register) and pudr (pull-up disable resistor). writing in these registers results in setting or clearing the corresponding bit in pusr (pull-up status register). reading a 1 in pusr means the pull-up is disabled and reading a 0 means the pull-up is enabled. control of the pull-up resistor is possible regardless of the configuration of the i/o line. after reset, all of the pull-ups are enabled, i.e. pusr resets at the value 0x0. 20.5.2 i/o line or peripheral function selection when a pin is multiplexed with one or two periph eral functions, the selection is controlled with the registers per (pio enable register) and pdr (pio disable register). the register psr (pio status register) is the result of the set and clear registers and indicates whether the pin is controlled by the corresponding peripheral or by the pio controller. a value of 0 indicates that the pin is controlled by the corresponding on-chip peripheral selected in the absr (ab select status register). a value of 1 indicates the pin is controlled by the pio controller. if a pin is used as a general purpose i/o line (not multiplexed with an on-chip peripheral), per and pdr have no effect and psr returns 1 for the corresponding bit. after reset, most generally, the i/o lines are controlled by the pio controller, i.e. psr resets at 1. however, in some events, it is important that pio lines are controlled by the peripheral (as in the case of memory chip select lines that must be driven inactive after reset or for address lines that must be driven low for booting out of an external memory). thus, the reset value of psr is defined at the product level, depending on the multiplexing of the device. 20.5.3 peripheral a or b selection the pio controller provides multiplexing of up to two peripheral functions on a single pin. the selection is performed by writ ing asr (a select register) and bsr (select b register). absr (ab select status register) indicates which peri pheral line is currently selected. for each pin, the corresponding bit at level 0 means peripheral a is selected whereas the corresponding bit at level 1 indicates that pe ripheral b is selected. note that multiplexing of peripheral lines a and b only affects the output line. the peripheral input lines are always connected to the pin input. after reset, absr is 0, thus indicating that all the pio lines are configured on peripheral a. how- ever, peripheral a generally does not drive the pin as the pio controller resets in i/o line mode. writing in asr and bsr manages absr regardless of the configuration of the pin. however, assignment of a pin to a peripheral function requires a write in the corresponding peripheral selection register (asr or bsr) in addition to a write in pdr. 20.5.4 output control when the i/0 line is assigned to a peripheral function, i.e. the corresponding bit in psr is at 0, the drive of the i/o line is controlled by the peripheral. peripheral a or b, depending on the value in absr, determines whether the pin is driven or not. when the i/o line is controlled by the pio controller, the pin can be configured to be driven. this is done by writing oer (output enable register) and odr (output disable register). the results of these write operations are detected in osr (output status register). when a bit in this
245 32015a?avr32?02/07 AT32AP7001 register is at 0, the corresponding i/o line is used as an input only. when the bit is at 1, the cor- responding i/o line is driven by the pio controller. the level driven on an i/o line can be determined by writing in sodr (set output data register) and codr (clear output data register). these write operations respectively set and clear odsr (output data status register), which represents the data driven on the i/o lines. writing in oer and odr manages osr whether the pin is configured to be controlled by the pio con- troller or assigned to a peripheral function. this enables configuration of the i/o line prior to setting it to be managed by the pio controller. similarly, writing in sodr and co dr effects odsr. this is importan t as it defines the first level driven on the i/o line. 20.5.5 synchronous data output controlling all paralle l busses using several pios requires two successive write operations in the sodr and codr registers. this may lead to unexpected transient values. the pio controller offers a direct control of pio outputs by single write access to odsr (output data status regis- ter). only bits unmasked by oswsr (output write status register) are written. the mask bits in the owsr are set by writing to ower (output write enable register) and cleared by writing to owdr (output write disable register). after reset, the synchronous data output is disabled on all the i/o lines as owsr resets at 0x0. 20.5.6 output line timings figure 20-4 shows how the outputs are driven either by writing sodr or codr, or by directly writing odsr. this last case is valid only if the corresponding bit in owsr is set. figure 20-4 also shows when the feedback in pdsr is available. figure 20-4. output line timings 20.5.7 inputs the level on each i/o line can be read through pdsr (pin data status register). this register indicates the level of the i/o lines regardless of their configuration, whether uniquely as an input or driven by the pio controller or driven by a peripheral. reading the i/o line levels requires the clock of the pio controller to be enabled, otherwise pdsr reads the levels present on the i/o line at the time the clock was disabled. 2 cycles peripheral bus access 2 cycles peripheral bus access mck write pio_sodr write pio_odsr at 1 pio_odsr pio_pdsr write pio_codr write pio_odsr at 0
246 32015a?avr32?02/07 AT32AP7001 20.5.8 input glitch filtering optional input glitch filters are independently programmable on each i/o line. when the glitch fil- ter is enabled, a glitch with a duration of less than 1/2 master clock (mck) cycle is automatically rejected, while a pulse with a duration of 1 mast er clock cycle or more is accepted. for pulse durations between 1/2 master clock cycle and 1 master clock cycle the pulse may or may not be taken into account, depending on the precise timing of its occurrence. thus for a pulse to be visible it must exceed 1 master clock cycle, whereas for a glitch to be reliably filtered out, its duration must not exceed 1/2 master clock cycle. the filter introduces one master clock cycle latency if the pin level change occurs before a rising edge. however, this latency does not appear if the pin level chan ge occurs before a falling ed ge. this is illustrated in figure 20-5 . the glitch filters are controlled by the register set; ifer (input filter enable register), ifdr (input filter disable register) and ifsr (input filter status register). writing ifer and ifdr respectively sets and clears bits in ifsr. this last register enables the glitch filter on the i/o lines. when the glitch filter is enabled, it does not modify the behavior of the inputs on the peripherals. it acts only on the value read in pdsr and on the input change interrupt detection. the glitch fil- ters require that the pio controller clock is enabled. figure 20-5. input glitch filter timing 20.5.9 input change interrupt the pio controller can be programmed to generate an interrupt when it detects an input change on an i/o line. the input change interrupt is controlled by writing ier (interrupt enable register) and idr (interrupt disable register), which respectively enable and disable the input change interrupt by setting and clearing the corresponding bit in imr (interrupt mask register). as input change detection is possible only by comparing two successive samplings of the input of the i/o line, the pio controller clock must be enabled. the input change interrupt is available, regard- less of the configuration of the i/o line, i.e. configured as an input only, controlled by the pio controller or assigned to a peripheral function. when an input change is detected on an i/o line, the corresponding bit in isr (interrupt status register) is set. if the corresponding bit in imr is set, the pio controller interrupt line is asserted. the interrupt signals of the thirty-two channels are ored-wired together to generate a single interrupt signal to the interrupt controller. when the software reads isr, all the interrupts are automatically cleared. th is signifies that all the interrupts that are pending when isr is read must be handled. mck pin level pio_pdsr if pio_ifsr = 0 pio_pdsr if pio_ifsr = 1 1 cycle 1 cycle 1 cycle up to 1.5 cycles 2 cycles up to 2.5 cycles up to 2 cycles 1 cycle 1 cycle
247 32015a?avr32?02/07 AT32AP7001 figure 20-6. input change interrupt timings 20.6 i/o lines programming example the programing example as shown in table 20-1 below is used to define the following configuration. ? 4-bit output port on i/o lines 0 to 3, (should be written in a single write operation) ? four output signals on i/o lines 4 to 7 (to drive leds for example) ? four input signals on i/o lines 8 to 11 (to read push-button states for example), with pull-up resistors, glitch filters and input change interrupts ? four input signals on i/o line 12 to 15 to read an external device status (polled, thus no input change interrupt), no pull-up resistor, no glitch filter ? i/o lines 16 to 19 assigned to peripheral a functions with pull-up resistor ? i/o lines 20 to 23 assigned to peripheral b functions, no pull-up resistor ? i/o line 24 to 27 assigned to peripheral a with input change interrupt and pull-up resistor mck pin level read pio_isr peripheral bus access pio_isr peripheral bus access
248 32015a?avr32?02/07 AT32AP7001 table 20-1. programming example register value to be written per 0x0000 ffff pdr 0x0fff 0000 oer 0x0000 00ff odr 0x0fff ff00 ifer 0x0000 0f00 ifdr 0x0fff f0ff sodr 0x0000 0000 codr 0x0fff ffff ier 0x0f00 0f00 idr 0x00ff f0ff pudr 0x00f0 00f0 puer 0x0f0f ff0f asr 0x0f0f 0000 bsr 0x00f0 0000 ower 0x0000 000f owdr 0x0fff fff0
249 32015a?avr32?02/07 AT32AP7001 20.7 user interface each i/o line controlled by the pio controller is associated with a bit in each of the pio control- ler user interface registers. each register is 32 bits wide. if a parallel i/o line is not defined, writing to the corresponding bits has no effect. undefined bits read zero. if the i/o line is not mul- tiplexed with any peripheral, the i/o line is controlled by the pio controller and psr returns 1 systematically. table 20-2. register mapping offset register name access reset value 0x0000 pio enable register per write-only ? 0x0004 pio disable register pdr write-only ? 0x0008 pio status register (1) psr read-only 0x0000 0000 0x000c reserved 0x0010 output enable register oer write-only ? 0x0014 output disable register odr write-only ? 0x0018 output status regi ster osr read-only 0x0000 0000 0x001c reserved 0x0020 glitch input filter en able register ifer write-only ? 0x0024 glitch input filter dis able register ifdr write-only ? 0x0028 glitch input filter status register ifsr read-only 0x0000 0000 0x002c reserved 0x0030 set output data register sodr write-only ? 0x0034 clear output data register codr write-only ? 0x0038 output data status register (2) odsr read-only 0x0000 0000 0x003c pin data status register (3) pdsr read-only 0x0040 interrupt enable register ier write-only ? 0x0044 interrupt disable register idr write-only ? 0x0048 interrupt mask register imr read-only 0x0000 0000 0x004c interrupt status register (4) isr read-only 0x0000 0000 0x0050 multi-driver enable register mddr write-only 0x0054 multi-driver disable register mder write-only 0x0058 multi-driver status register mdsr read-only 0x005c reserved 0x0060 pull-up disable register pudr write-only ? 0x0064 pull-up enable register puer write-only ? 0x0068 pad pull-up status r egister pusr read-only 0x0000 0000 0x006c reserved
250 32015a?avr32?02/07 AT32AP7001 notes: 1. reset value of psr depends on the product implementation. 2. odsr is read-only or read/write depending on owsr i/o lines. 3. reset value of pdsr depends on the level of the i/o lines. 4. isr is reset at 0x0. however, the first read of the register may read a different value as input changes may have occurred. 5. only this set of registers clears the status by writing 1 in the first register and sets the st atus by writing 1 in the secon d register. 0x0070 peripheral a select register (5) asr write-only ? 0x0074 peripheral b select register (5) bsr write-only ? 0x0078 ab status register (5) absr read-only 0x0000 0000 0x007c to 0x009c reserved 0x00a0 output write enable ower write-only ? 0x00a4 output write disable owdr write-only ? 0x00a8 output write status re gister owsr read-only 0x0000 0000 0x00ac reserved table 20-2. register mapping (continued) offset register name access reset value
251 32015a?avr32?02/07 AT32AP7001 20.7.1 pio controller pio enable register name: per access type: write-only ? p0-p31: pio enable 0 = no effect. 1 = enables the pio to control the corresponding pin (disables peripheral control of the pin). 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
252 32015a?avr32?02/07 AT32AP7001 20.7.2 pio controller pio disable register name: pdr access type: write-only ? p0-p31: pio disable 0 = no effect. 1 = disables the pio from controllin g the corresponding pin (enables peripheral contro l of the pin). 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
253 32015a?avr32?02/07 AT32AP7001 20.7.3 pio controller pio status register name: psr access type: read-only ? p0-p31: pio status 0 = pio is inactive on the corresponding i/o line (peripheral is active). 1 = pio is active on the corresponding i/o line (peripheral is inactive). 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
254 32015a?avr32?02/07 AT32AP7001 20.7.4 pio controller output enable register name: oer access type: write-only ? p0-p31: output enable 0 = no effect. 1 = enables the output on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
255 32015a?avr32?02/07 AT32AP7001 20.7.5 pio controller output disable register name: odr access type: write-only ? p0-p31: output disable 0 = no effect. 1 = disables the output on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
256 32015a?avr32?02/07 AT32AP7001 20.7.6 pio controller output status register name: osr access type: read-only ? p0-p31: output status 0 = the i/o line is a pure input. 1 = the i/o line is enabled in output. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
257 32015a?avr32?02/07 AT32AP7001 20.7.7 pio controller glitch input filter enable register name: ifer access type: write-only ? p0-p31: input filter enable 0 = no effect. 1 = enables the input glitch filter on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
258 32015a?avr32?02/07 AT32AP7001 20.7.8 pio controller glitch input filter disable register name: ifdr access type: write-only ? p0-p31: input filter disable 0 = no effect. 1 = disables the input glitch filter on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
259 32015a?avr32?02/07 AT32AP7001 20.7.9 pio controller glitch input filter status register name: ifsr access type: read-only ? p0-p31: input filer status 0 = the input glitch filter is disabled on the i/o line. 1 = the input glitch filter is enabled on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
260 32015a?avr32?02/07 AT32AP7001 20.7.10 pio controller set output data register name: sodr access type: write-only ? p0-p31: set output data 0 = no effect. 1 = sets the data to be driven on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
261 32015a?avr32?02/07 AT32AP7001 20.7.11 pio controller clear output data register name: codr access type: write-only ? p0-p31: set output data 0 = no effect. 1 = clears the data to be driven on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
262 32015a?avr32?02/07 AT32AP7001 20.7.12 pio controller output data status register name: odsr access type: read-only or read/write ? p0-p31: output data status 0 = the data to be driven on the i/o line is 0. 1 = the data to be driven on the i/o line is 1. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
263 32015a?avr32?02/07 AT32AP7001 20.7.13 pio controller pin data status register name: pdsr access type: read-only ? p0-p31: output data status 0 = the i/o line is at level 0. 1 = the i/o line is at level 1. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
264 32015a?avr32?02/07 AT32AP7001 20.7.14 pio controller interrupt enable register name: ier access type: write-only ? p0-p31: input change interrupt enable 0 = no effect. 1 = enables the input change interrupt on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
265 32015a?avr32?02/07 AT32AP7001 20.7.15 pio controller interrupt disable register name: idr access type: write-only ? p0-p31: input change interrupt disable 0 = no effect. 1 = disables the input change interrupt on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
266 32015a?avr32?02/07 AT32AP7001 20.7.16 pio controller interrupt mask register name: imr access type: read-only ? p0-p31: input change interrupt mask 0 = input change interrupt is disabled on the i/o line. 1 = input change interrupt is enabled on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
267 32015a?avr32?02/07 AT32AP7001 20.7.17 pio controller interrupt status register name: isr access type: read-only ? p0-p31: input change interrupt status 0 = no input change has been detected on the i/o line since isr was last read or since reset. 1 = at least one input change has been detected on the i/o line since isr was last read or since reset. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
268 32015a?avr32?02/07 AT32AP7001 20.7.18 pio controller multi-driver enable register name: mder access type: write-only this register is used to enable pio output drivers to be conf igured as open drain to support external drivers on the same pin. ?p0-p31: 0 = no effect. 1 = enables multi-drive option on the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
269 32015a?avr32?02/07 AT32AP7001 20.7.19 pio controller multi-driver disable register name: mddr access type: write-only this register is used to diasble the open drain configuration of the output buffer. ?p0-p31: 0 = no effect. 1 = disables multi-drive option on the corresponding pin. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
270 32015a?avr32?02/07 AT32AP7001 20.7.20 pio controller multi-driver status register name: mdsr access type: read-only this register indicates which pins are configured with open drain drivers. ?p0-p31: 0 = pio is not configured as an open drain. 1 = pio is configured as an open drain. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
271 32015a?avr32?02/07 AT32AP7001 20.7.21 pio pull up disable register name: pudr access type: write-only ? p0-p31: pull up disable. 0 = no effect. 1 = disables the pull up resistor on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
272 32015a?avr32?02/07 AT32AP7001 20.7.22 pio pull up enable register name: puer access type: write-only ? p0-p31: pull up enable. 0 = no effect. 1 = enables the pull up resistor on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
273 32015a?avr32?02/07 AT32AP7001 20.7.23 pio pull up status register name: pusr access type: read-only ? p0-p31: pull up status. 0 = pull up resistor is enabled on the i/o line. 1 = pull up resistor is disabled on the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
274 32015a?avr32?02/07 AT32AP7001 20.7.24 pio peripheral a select register name: asr access type: write-only ? p0-p31: peripheral a select. 0 = no effect. 1 = assigns the i/o line to the peripheral a function. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
275 32015a?avr32?02/07 AT32AP7001 20.7.25 pio peripheral b select register name: bsr access type: write-only ? p0-p31: peripheral b select. 0 = no effect. 1 = assigns the i/o line to the peripheral b function. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
276 32015a?avr32?02/07 AT32AP7001 20.7.26 pio peripheral a b status register name: absr access type: read-only ? p0-p31: peripheral a b status. 0 = the i/o line is assigned to the peripheral a. 1 = the i/o line is assigned to the peripheral b. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
277 32015a?avr32?02/07 AT32AP7001 20.7.27 pio output write enable register name: ower access type: write-only ? p0-p31: output write enable. 0 = no effect. 1 = enables writing od sr for the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
278 32015a?avr32?02/07 AT32AP7001 20.7.28 pio output write disable register name: owdr access type: write-only ? p0-p31: output write disable. 0 = no effect. 1 = disables writing odsr for the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
279 32015a?avr32?02/07 AT32AP7001 20.7.29 pio output write status register name: owsr access type: read-only ? p0-p31: output write status. 0 = writing odsr does not affect the i/o line. 1 = writing odsr affects the i/o line. 31 30 29 28 27 26 25 24 p31 p30 p29 p28 p27 p26 p25 p24 23 22 21 20 19 18 17 16 p23 p22 p21 p20 p19 p18 p17 p16 15 14 13 12 11 10 9 8 p15 p14 p13 p12 p11 p10 p9 p8 76543210 p7 p6 p5 p4 p3 p2 p1 p0
280 32015a?avr32?02/07 AT32AP7001 21. serial peripheral interface (spi) rev: 1.7.1.0 21.1 features ? supports communication with serial external devices ? four chip selects with external decoder support allow communication with up to 15 peripherals ? serial memories, such as dataflash and 3-wire eeproms ? serial peripherals, such as adcs, dacs, lcd controllers, can controllers and sensors ? external co-processors ? master or slave serial peripheral bus interface ? 8- to 16-bit programmable data length per chip select ? programmable phase and polarity per chip select ? programmable transfer delays between consec utive transfers and be tween clock and data per chip select ? programmable delay between consecutive transfers ? selectable mode fault detection ? connection to pdc channel capabi lities optimizes data transfers ? one channel for the receiver, on e channel for the transmitter ? next buffer support 21.2 description the serial peripheral interface (spi) circuit is a synchronous serial data link that provides com- munication with external devices in master or slave mode. it also enables communication between processors if an external processor is connected to the system. the serial peripheral interface is essentially a shift register that serially transmits data bits to other spis. during a data transfer, one spi syste m acts as the ?master?' which controls the data flow, while the other devices act as ?slaves'' whic h have data shifted into and out by the master. different cpus can take turn being masters (multiple master protocol opposite to single master protocol where one cpu is always the master while all of the others are always slaves) and one master may simultaneously shift da ta into multiple slaves. howeve r, only one slave may drive its output to write data back to the master at any given time. a slave device is selected when the master asse rts its nss signal. if multiple slave devices exist, the master generates a separate slav e select signal for each slave (npcs). the spi system consists of two data lines and two control lines: ? master out slave in (mosi): this data line supplies the output data from the master shifted into the input(s) of the slave(s). ? master in slave out (miso): this data line supplies the output data from a slave to the input of the master. there may be no more than one slave transmitting data during any particular transfer. ? serial clock (spck): this control line is driven by the master and regulates the flow of the data bits. the master may transmit data at a variety of baud rates; the spck line cycles once for each bit that is transmitted. ? slave select (nss): this control line allows slaves to be turned on and off by hardware.
281 32015a?avr32?02/07 AT32AP7001 21.3 block diagram figure 21-1. block diagram spi interface interrupt control pio pdc power manager mck spi interrupt spck miso mosi npcs0/nss npcs1 npcs2 div npcs3 ral bus mck 32 (1)
282 32015a?avr32?02/07 AT32AP7001 21.4 application block diagram figure 21-2. application block diagram: single master/multiple slave implementation spi master spck miso mosi npcs0 npcs1 npcs2 spck miso mosi nss slave 0 spck miso mosi nss slave 1 spck miso mosi nss slave 2 nc npcs3
283 32015a?avr32?02/07 AT32AP7001 21.5 signal description table 21-1. signal description pin name pin description type master slave miso master in slave out input output mosi master out slave in output input spck serial clock output input npcs1-npcs3 peripheral chip selects output unused npcs0/nss peripheral chip select/slave select output input
284 32015a?avr32?02/07 AT32AP7001 21.6 product dependencies 21.6.1 i/o lines the pins used for interfacing the compliant ex ternal devices may be multiplexed with pio lines. the programmer must first program the pio controllers to assign the spi pins to their peripheral functions. 21.6.2 power management the spi clock is generated by the power manager. before using the spi, the programmer must ensure that the spi clock is enabled in the power manager. in the spi description, master clock (mck) is the clock of the per ipheral bus to which the spi is connected. 21.6.3 interrupt the spi interface has an interrupt line connected to the interrupt controller. handling the spi interrupt requires programming the interrupt controller before configuring the spi.
285 32015a?avr32?02/07 AT32AP7001 21.7 functional description 21.7.1 modes of operation the spi operates in master mode or in slave mode. operation in master mode is programmed by writing at 1 the mstr bit in the mode register. the pins npcs0 to npcs3 are all configured as outputs, the spck pin is driven, the miso line is wired on the receiver input and the mosi line driven as an output by the transmitter. if the mstr bit is written at 0, the spi operates in slave mode. the miso line is driven by the transmitter output, the mosi line is wired on the re ceiver input, the spck pin is driven by the transmitter to synchronize the receiver. the npcs0 pin becomes an input, and is used as a slave select signal (nss). the pins npcs1 to npcs3 are not driven and can be used for other purposes. the data transfers are identically programmable for both modes of operations. the baud rate generator is activated only in master mode. 21.7.2 data transfer four combinations of polarity and phase are available for data transfers. the clock polarity is programmed with the cpol bit in the chip select register. the clock phase is programmed with the ncpha bit. these two parameters determine th e edges of the clock signal on which data is driven and sampled. each of the two parameters has two possible states, resulting in four possi- ble combinations that are incompatible with one another. thus, a master/slave pair must use the same parameter pair values to communicate. if multiple slaves are used and fixed in different configurations, the master must reconfigure itself each time it needs to communicate with a dif- ferent slave. table 21-2 shows the four modes and corresponding parameter settings. figure 21-3 and figure 21-4 show examples of data transfers. table 21-2. spi bus protocol mode spi mode cpol ncpha 001 100 211 310
286 32015a?avr32?02/07 AT32AP7001 figure 21-3. spi transfer format (ncpha = 1, 8 bits per transfer) figure 21-4. spi transfer format (ncpha = 0, 8 bits per transfer) 6 * spck (cpol = 0) spck (cpol = 1) mosi (from master) miso (from slave) nss (to slave) spck cycle (for reference) msb msb lsb lsb 6 6 5 5 4 4 3 3 2 2 1 1 * not defined, but normally msb of previous character received. 1 2345 78 6 * spck (cpol = 0) spck (cpol = 1) 1 2345 7 mosi (from master) miso (from slave) nss (to slave) spck cycle (for reference) 8 msb msb lsb lsb 6 6 5 5 4 4 3 3 1 1 * not defined but normally lsb of previous character transmitted. 2 2 6
287 32015a?avr32?02/07 AT32AP7001 21.7.3 master mode operations when configured in master mode, the spi uses the internal programmable baud rate generator as clock source. it fully controls the data transfers to and from the slave(s) connected to the spi bus. the spi drives the chip select line to the slave and the serial clock signal (spck). the spi features two holding registers, the transmit data register and the receive data regis- ter, and a single shift register. the holding registers maintain the data flow at a constant rate. after enabling the spi, a data transfer begins when the processor writes to the tdr (transmit data register). the written data is immediately transferred in the shift register and transfer on the spi bus starts. while the data in the shift register is shifted on the mosi line, the miso line is sampled and shifted in the shift register. transmission cannot occur without reception. before writing the tdr, the pcs field must be set in order to select a slave. if new data is written in tdr during the transfer, it stays in it until the current transfer is com- pleted. then, the received data is transferred from the shift register to rdr, the data in tdr is loaded in the shift register and a new transfer starts. the transfer of a data written in tdr in the shift register is indicated by the tdre bit (transmit data register empty) in the status register (s r). when new data is written in tdr, this bit is cleared. the tdre bit is used to trigger the tran smit pdc channel. the end of transfer is indicated by the txempty fl ag in the sr register. if a transfer delay (dly- bct) is greater than 0 for the last transfer, txempty is set after the completion of said delay. the master clock (mck) can be switched off at this time. the transfer of received data from the shift re gister in rdr is indicated by the rdrf bit (receive data register full) in the status r egister (sr). when the received data is read, the rdrf bit is cleared. if the rdr (receive data register) has not been read before new data is received, the overrun error bit (ovres) in sr is set. as long as this flag is set, data is loaded in rdr. the user has to read the status register to clear the ovres bit. figure 21-5 on page 288 shows a block diagram of the spi when operating in master mode. fig- ure 21-6 on page 289 shows a flow chart describing how transfers are handled.
288 32015a?avr32?02/07 AT32AP7001 21.7.3.1 master mode block diagram figure 21-5. master mode block diagram shift register spck mosi lsb msb miso spi_rdr rd spi clock tdre spi_tdr td rdrf ovres spi_csr0..3 cpol ncpha bits 0 1 fdiv mck mck/n baud rate generator spi_csr0..3 scbr npcs3 npcs0 npcs2 npcs1 npcs0 0 1 ps spi_mr pcs spi_tdr pcs modf current peripheral spi_rdr pcs spi_csr0..3 csaat pcsdec modfdis mstr
289 32015a?avr32?02/07 AT32AP7001 21.7.3.2 master mode flow diagram figure 21-6. master mode flow diagram s spi enable csaat ? ps ? 1 0 0 1 1 npcs = spi_tdr(pcs) npcs = spi_mr(pcs) delay dlybs serializer = spi_tdr(td) tdre = 1 data transfer spi_rdr(rd) = serializer rdrf = 1 tdre ? npcs = 0xf delay dlybcs fixed peripheral variable peripheral delay dlybct 0 1 csaat ? 0 tdre ? 1 0 ps ? 0 1 spi_tdr(pcs) = npcs ? no yes spi_mr(pcs) = npcs ? no npcs = 0xf delay dlybcs npcs = spi_tdr(pcs) npcs = 0xf delay dlybcs npcs = spi_mr(pcs), spi_tdr(pcs) fixed peripheral variable peripheral - npcs defines the current chip select - csaat, dlybs, dlybct refer to the fields of the chip select register corresponding to the current chip select - when npcs is 0xf, csaat is 0.
290 32015a?avr32?02/07 AT32AP7001 21.7.3.3 clock generation the spi baud rate clock is generated by dividing the master clock (mck) or the master clock divided by 32, by a value between 1 and 255. the selection between master clock or master clock divided by 32 is done by the fdiv value set in the mode register this allows a maximum operating baud rate at up to master clock and a minimum operating baud rate of mck divided by 255*32. programming the scbr field at 0 is forbidden. tr iggering a transfer while scbr is at 0 can lead to unpredictable results. at reset, scbr is 0 and the user has to program it at a valid value before performing the first transfer. the divisor can be defined independently for each chip select, as it has to be programmed in the scbr field of the chip select registers. this allows the spi to automatically adapt the baud rate for each interfaced peripheral without reprogramming. 21.7.3.4 transfer delays figure 21-7 shows a chip select transfer change and consecutive transfers on the same chip select. three delays can be programmed to modify the transfer waveforms: ? the delay between chip selects, programmable only once for all the chip selects by writing the dlybcs field in the mode register. allows insertion of a delay between release of one chip select and before assertion of a new one. ? the delay before spck, independently programmable for each chip select by writing the field dlybs. allows the start of spck to be delayed after the chip select has been asserted. ? the delay between consecutive transfers, independently programmable for each chip select by writing the dlybct field. allows insertion of a delay between two transfers occurring on the same chip select these delays allow the spi to be adapted to the interfaced peripherals and their speed and bus release time. figure 21-7. programmable delays dlybcs dlybs dlybct dlybct chip select 1 chip select 2 spck
291 32015a?avr32?02/07 AT32AP7001 21.7.3.5 peripheral selection the serial peripherals are selected through the assertion of the npcs0 to npcs3 signals. by default, all the npcs signals are high before and after each transfer. the peripheral selection can be performed in two different ways: ? fixed peripheral select: spi exchanges data with only one peripheral ? variable peripheral select: data can be exchanged with more than one peripheral fixed peripheral select is activated by writing t he ps bit to zero in mr (mode register). in this case, the current peripheral is defined by the pc s field in mr and the pcs field in tdr have no effect. variable peripheral select is activated by setting ps bit to one. the pcs field in tdr is used to select the current peripheral. this means that the peripheral selection can be defined for each new data. the fixed peripheral selection allows buffer transfers with a single peripheral. using the pdc is an optimal means, as the size of the data transfer between the memory and the spi is either 8 bits or 16 bits. however, changing the peripheral selection requires the mode register to be reprogrammed. the variable peripheral selection allows buffer transfers with multiple peripherals without repro- gramming the mode register. data written in tdr is 32 bits wide and defines the real data to be transmitted and the peripheral it is destined to. using the pdc in this mo de requires 32-bit wide buffers, with the data in the lsbs and the pcs and lastxfer fields in the msbs, however the spi still controls the number of bi ts (8 to16) to be tr ansferred through miso and mosi lines with the chip select configuration registers. this is not the optimal means in term of memory size for the buffers, but it provides a very effective means to exchange data with several peripherals without any intervention of the processor. 21.7.3.6 peripheral chip select decoding the user can program the spi to operate with up to 15 peripherals by decoding the four chip select lines, npcs0 to npcs3 with an external l ogic. this can be enabled by writing the pcs- dec bit at 1 in the mode register (mr). when operating without decoding, the spi makes sure that in any case only one chip select line is activated, i.e. driven low at a time. if two bits are defined low in a pcs field, only the lowest numbered chip select is driven low. when operating with decoding, the spi directly outputs the value defined by the pcs field of either the mode register or the transmit data register (depending on ps). as the spi sets a default value of 0xf on the chip select lines (i.e. all chip select lines at 1) when not processing any transfer, only 15 peripherals can be decoded. the spi has only four chip select registers, not 15. as a result, when decoding is activated, each chip select defines the characteristics of up to four peripherals. as an example, crs0 defines the characteristics of the externally decoded peripherals 0 to 3, corresponding to the pcs values 0x0 to 0x3. thus, the user has to make sure to connect compatible peripherals on the decoded chip select lines 0 to 3, 4 to 7, 8 to 11 and 12 to 14.
292 32015a?avr32?02/07 AT32AP7001 21.7.3.7 peripheral deselection when operating normally, as soon as the transfer of the last data written in tdr is completed, the npcs lines all rise. this might lead to runtime error if the processor is too long in responding to an interrupt, and thus might lead to difficulties for interfacing with some serial peripherals requiring the chip select li ne to remain active during a full set of transfers. to facilitate interfacing with such devices, the chip select regist er can be prog rammed with the csaat bit (chip select active afte r transfer) at 1. this allows th e chip select lines to remain in their current state (low = active) until transfer to another peripheral is required. figure 21-8 shows different peripheral deselection cases and the effect of the csaat bit. figure 21-8. peripheral deselection a npcs[0..3] write spi_tdr tdre npcs[0..3] write spi_tdr tdre npcs[0..3] write spi_tdr tdre dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs pcs = a dlybcs dlybct a pcs = b b dlybcs dlybct pcs=a a dlybcs dlybct a pcs = a a a dlybct aa csaat = 0 dlybct aa csaat = 1 a
293 32015a?avr32?02/07 AT32AP7001 21.7.3.8 mode fault detection a mode fault is detected when the spi is programmed in master mode and a low level is driven by an external master on the npcs0/nss signa l. npcs0, mosi, miso and spck must be con- figured in open-drain through the pio controller, so that external pull up resistors are needed to guarantee high level. when a mode fault is detected, the modf bit in the sr is set until the sr is read and the spi is automatically disabled until re-enabled by writing the spien bit in the cr (control register) at 1. by default, the mode fault detection circuitr y is enabled. the user can disable mode fault detection by setting the modfdis bit in the spi mode register (mr). 21.7.4 spi slave mode when operating in slave mode, the spi processes data bits on the clock provided on the spi clock pin (spck). the spi waits for nss to go active before receiving the serial clock from an external master. when nss falls, the clock is validated on the serializer, which processes the number of bits defined by the bits field of the chip select register 0 (csr0). these bits are processed follow- ing a phase and a polarity defined respectively by the ncpha and cpol bits of the csr0. note that bits, cpol and ncpha of the other chip select registers have no effect when the spi is programmed in slave mode. the bits are shifted out on the miso line and sampled on the mosi line. when all the bits are processed, the received data is transferred in the receive data register and the rdrf bit rises. if rdrf is already high wh en the data is transf erred, the overrun bit rises and the data transfer to rdr is aborted. when a transfer starts, the data shifted out is the data present in the shift register. if no data has been written in the transmit data register (t dr), the last data received is transferred. if no data has been received since the last reset, all bits are transmitted low, as the shift register resets at 0. when a first data is written in tdr, it is trans ferred immediately in the shift register and the tdre bit rises. if new data is wr itten, it remains in tdr until a transfer occurs, i.e. nss falls and there is a valid clock on the spck pin. when the transfer occurs, the last data written in tdr is transferred in the shift register and the tdre bit rises. this enables frequent updates of critical variables with single transfers. then, a new data is loaded in the shift register from the transmit data register. in case no character is ready to be transmitted, i.e. no c haracter has been written in tdr since the last load from tdr to the shift register, the shift register is not modified and the last received character is retransmitted. figure 21-9 shows a block diagram of the spi when operating in slave mode.
294 32015a?avr32?02/07 AT32AP7001 figure 21-9. slave mode functional block diagram shift register spck spiens lsb msb nss mosi spi_rdr rd spi clock tdre spi_tdr td rdrf ovres spi_csr0 cpol ncpha bits fload spien spidis miso
295 32015a?avr32?02/07 AT32AP7001 21.8 serial peripheral inte rface (spi) user interface table 21-3. spi register mapping offset register register name access reset 0x00 control register cr write-only --- 0x04 mode register mr read/write 0x0 0x08 receive data register rdr read-only 0x0 0x0c transmit data register tdr write-only --- 0x10 status register sr read-only 0x000000f0 0x14 interrupt enable register ier write-only --- 0x18 interrupt disable register idr write-only --- 0x1c interrupt mask register imr read-only 0x0 0x20 - 0x2c reserved 0x30 chip select register 0 csr0 read/write 0x0 0x34 chip select register 1 csr1 read/write 0x0 0x38 chip select register 2 csr2 read/write 0x0 0x3c chip select register 3 csr3 read/write 0x0 0x100 - 0x124 reserved for the pdc
296 32015a?avr32?02/07 AT32AP7001 21.8.1 spi control register name: cr access type: write-only ? spien: spi enable 0 = no effect. 1 = enables the spi to transfer and receive data. ? spidis: spi disable 0 = no effect. 1 = disables the spi. as soon as spdis is set, spi finishes its transfer. all pins are set in input mode and no data is received or transmitted. if a transfer is in progress, the transfer is finished before the spi is disabled. if both spien and spidis are equal to one when the control register is written, the spi is disabled. ? swrst: spi software reset 0 = no effect. 1 = reset the spi. a software-triggered hardware reset of the spi interface is performed. the spi is in slave mode after a software reset. pdc channels are not affected by software reset. ? lastxfer: last transfer 0 = no effect. 1 = the current npcs will be deasserted afte r the character written in td has been transferred. when csaat is set, this allows to close the communication with the current serial peri pheral by raising the correspo nding npcs line as soon as td transfer has completed. 31 30 29 28 27 26 25 24 ???????lastxfer 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 swrst?????spidisspien
297 32015a?avr32?02/07 AT32AP7001 21.8.2 spi mode register name: mr access type: read/write ? mstr: master/slave mode 0 = spi is in slave mode. 1 = spi is in master mode. ? ps: peripheral select 0 = fixed peripheral select. 1 = variable peripheral select. ? pcsdec: chip select decode 0 = the chip selects are directly connected to a peripheral device. 1 = the four chip select lines are connected to a 4- to 16-bit decoder. when pcsdec equals one, up to 15 chip select signals can be generated with the four lines using an external 4- to 16-bit decoder. the chip select registers define the characteristics of the 15 chip selects according to the following rules: csr0 defines peripheral chip select signals 0 to 3. csr1 defines peripheral chip select signals 4 to 7. csr2 defines peripheral chip select signals 8 to 11. csr3 defines peripheral chip select signals 12 to 14. ? fdiv: clock selection 0 = the spi operates at mck. 1 = the spi operates at mck/n. ? modfdis: mode fault detection 0 = mode fault detection is enabled. 1 = mode fault detection is disabled. ? llb: local loopback enable 0 = local loopback path disabled. 1 = local loopback path enabled. llb controls the local loopback on the data serializer for test ing in master mode only. miso is internally connected to mosi. 31 30 29 28 27 26 25 24 dlybcs 23 22 21 20 19 18 17 16 ???? pcs 15 14 13 12 11 10 9 8 ???????? 76543210 llb ? ? modfdis fdiv pcsdec ps mstr
298 32015a?avr32?02/07 AT32AP7001 ? pcs: peripheral chip select this field is only used if fixed peripheral select is active (ps = 0). if pcsdec = 0: pcs = xxx0 npcs[3:0] = 1110 pcs = xx01 npcs[3:0] = 1101 pcs = x011 npcs[3:0] = 1011 pcs = 0111 npcs[3:0] = 0111 pcs = 1111 forbidden (no peripheral is selected) (x = don?t care) if pcsdec = 1: npcs[3:0] output signals = pcs. ? dlybcs: delay between chip selects this field defines the delay from npcs inactive to the ac tivation of another npcs. the dlybcs time guarantees non-over- lapping chip selects and solves bus contentions in case of peripherals having long data float times. if dlybcs is less than or equal to six, six mck periods (or 6*n mck period s if fdiv is set) will be inserted by default. otherwise, the following equat ion determines the delay: if fdiv is 0: if fdiv is 1: delay between chip selects dlybcs mck ---------------------- - = delay between chip selects dlybcs n mck --------------------------------- =
299 32015a?avr32?02/07 AT32AP7001 21.8.3 spi receive data register name: rdr access type: read-only ? rd: receive data data received by the spi interface is stored in this register right-justified. unused bits read zero. ? pcs: peripheral chip select in master mode only, these bits indicate the value on the npcs pins at the end of a transfer. otherwise, these bits read zero. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???? pcs 15 14 13 12 11 10 9 8 rd 76543210 rd
300 32015a?avr32?02/07 AT32AP7001 21.8.4 spi transmit data register name: tdr access type: write-only ? td: transmit data data to be transmitted by the spi interface is stored in this register. information to be transmitted must be written to the transmit data register in a right-justified format. ? pcs: peripheral chip select this field is only used if variable peripheral select is active (ps = 1). if pcsdec = 0: pcs = xxx0 npcs[3:0] = 1110 pcs = xx01 npcs[3:0] = 1101 pcs = x011 npcs[3:0] = 1011 pcs = 0111 npcs[3:0] = 0111 pcs = 1111 forbidden (no peripheral is selected) (x = don?t care) if pcsdec = 1: npcs[3:0] output signals = pcs ? lastxfer: last transfer 0 = no effect. 1 = the current npcs will be deasserted afte r the character written in td has been transferred. when csaat is set, this allows to close the communication with the current serial peri pheral by raising the correspo nding npcs line as soon as td transfer has completed. this field is only used if variable peripheral select is active (ps = 1). 31 30 29 28 27 26 25 24 ???????lastxfer 23 22 21 20 19 18 17 16 ???? pcs 15 14 13 12 11 10 9 8 td 76543210 td
301 32015a?avr32?02/07 AT32AP7001 21.8.5 spi status register name: sr access type: read-only ? rdrf: receive data register full 0 = no data has been received since the last read of rdr 1 = data has been received and the receiv ed data has been transferred from the serializer to rdr since the last read of rdr. ? tdre: transmit data register empty 0 = data has been written to tdr and not yet transferred to the serializer. 1 = the last data written in the transmit data register has been transferred to the serializer. tdre equals zero when the spi is disabled or at reset. the spi enable command sets this bit to one. ? modf: mode fault error 0 = no mode fault has been detected since the last read of sr. 1 = a mode fault occurred since the last read of the sr. ? ovres: overrun error status 0 = no overrun has been detected since the last read of sr. 1 = an overrun has occurred since the last read of sr. an overrun occurs when rdr is loaded at least twice from the seri alizer since the last read of the rdr. ? endrx: end of rx buffer 0 = the receive counter register has not reach ed 0 since the last write in rcr or rncr. 1 = the receive counter register has reached 0 since the last write in rcr or rncr. ? endtx: end of tx buffer 0 = the transmit counter register has not reache d 0 since the last write in tcr or tncr. 1 = the transmit counter register has reached 0 since the last write in tcr or tncr. ? rxbuff: rx buffer full 0 = rcr or rncr has a value other than 0. 1 = both rcr and rncr has a value of 0. ? txbufe: tx buffer empty 0 = tcr or tncr has a value other than 0. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????spiens 15 14 13 12 11 10 9 8 ??????txemptynssr 76543210 txbufe rxbuff endtx endrx ovres modf tdre rdrf
302 32015a?avr32?02/07 AT32AP7001 1 = both tcr and tncr has a value of 0. ? nssr: nss rising 0 = no rising edge detected on nss pin since last read. 1 = a rising edge occurred on nss pin since last read. ? txempty: transmission registers empty 0 = as soon as data is written in tdr. 1 = tdr and internal shifter are empty. if a transfer delay has been defined, txempty is set after the completion of such delay. ? spiens: spi enable status 0 = spi is disabled. 1 = spi is enabled.
303 32015a?avr32?02/07 AT32AP7001 21.8.6 spi interrupt enable register name: ier access type: write-only ? rdrf: receive data register full interrupt enable ? tdre: spi transmit data regi ster empty interrupt enable ? modf: mode fault error interrupt enable ? ovres: overrun error interrupt enable ? endrx: end of receive bu ffer interrupt enable ? endtx: end of transmit buffer interrupt enable ? rxbuff: receive buffer full interrupt enable ? txbufe: transmit buffer empty interrupt enable ? txempty: transmission registers empty enable ? nssr: nss rising interrupt enable 0 = no effect. 1 = enables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????txemptynssr 76543210 txbufe rxbuff endtx endrx ovres modf tdre rdrf
304 32015a?avr32?02/07 AT32AP7001 21.8.7 spi interrupt disable register name: idr access type: write-only ? rdrf: receive data register full interrupt disable ? tdre: spi transmit data register empty interrupt disable ? modf: mode fault error interrupt disable ? ovres: overrun error interrupt disable ? endrx: end of receive bu ffer interrupt disable ? endtx: end of transmit buffer interrupt disable ? rxbuff: receive buffer full interrupt disable ? txbufe: transmit buffer empty interrupt disable ? txempty: transmission registers empty disable ? nssr: nss rising interrupt disable 0 = no effect. 1 = disables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????txemptynssr 76543210 txbufe rxbuff endtx endrx ovres modf tdre rdrf
305 32015a?avr32?02/07 AT32AP7001 21.8.8 spi interrupt mask register name: imr access type: read-only ? rdrf: receive data register full interrupt mask ? tdre: spi transmit data register empty interrupt mask ? modf: mode fault error interrupt mask ? ovres: overrun error interrupt mask ? endrx: end of receive buffer interrupt mask ? endtx: end of transmit buffer interrupt mask ? rxbuff: receive buffer full interrupt mask ? txbufe: transmit buffer empty interrupt mask ? txempty: transmission registers empty mask ? nssr: nss rising interrupt mask 0 = the corresponding interrupt is not enabled. 1 = the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????txemptynssr 76543210 txbufe rxbuff endtx endrx ovres modf tdre rdrf
306 32015a?avr32?02/07 AT32AP7001 21.8.9 spi chip select register name: csr0... csr3 access type: read/write ? cpol: clock polarity 0 = the inactive state value of spck is logic level zero. 1 = the inactive state value of spck is logic level one. cpol is used to determine the inactive state value of the serial clock (spck). it is used with ncpha to produce the required clock/data relationship between master and slave devices. ? ncpha: clock phase 0 = data is changed on the leading edge of spck and captured on the following edge of spck. 1 = data is captured on the leading edge of spck and changed on the following edge of spck. ncpha determines which edge of spck causes data to change and which edge causes data to be captured. ncpha is used with cpol to produce the required clock/da ta relationship between master and slave devices. ? csaat: chip select active after transfer 0 = the peripheral chip select line rises as soon as the last transfer is achieved. 1 = the peripheral chip select does not rise after the last transfer is achieved. it remains active until a new transfer is requested on a different chip select. ? bits: bits per transfer the bits field determines the number of data bits transferred. reserved values should not be used, see table 21-4 on page 307 . 31 30 29 28 27 26 25 24 dlybct 23 22 21 20 19 18 17 16 dlybs 15 14 13 12 11 10 9 8 scbr 76543210 bits csaat ? ncpha cpol
307 32015a?avr32?02/07 AT32AP7001 . ? scbr: serial clock baud rate in master mode, the spi interface uses a modulus counter to derive the spck baud rate from the master clock mck. the baud rate is selected by writing a value from 1 to 255 in the scbr field. the following equations determine the spck baud rate: if fdiv is 0: if fdiv is 1: note: n = 32 programming the scbr field at 0 is forbidden. triggering a trans fer while scbr is at 0 can le ad to unpredictable results. at reset, scbr is 0 and the user has to program it at a valid value before performing the first transfer. ? dlybs: delay before spck this field defines the delay from npcs valid to the first valid spck transition. when dlybs equals zero, the npcs valid to spck transition is 1/2 the spck clock period. table 21-4. bits, bits per transfer bits bits per transfer 0000 8 0001 9 0010 10 0011 11 0100 12 0101 13 0110 14 0111 15 1000 16 1001 reserved 1010 reserved 1011 reserved 1100 reserved 1101 reserved 1110 reserved 1111 reserved spck baudrate mck scbr -------------- - = spck baudrate mck nscbr () ------------------------------ =
308 32015a?avr32?02/07 AT32AP7001 otherwise, the following equations determine the delay: if fdiv is 0: if fdiv is 1: note: n = 32 ? dlybct: delay between consecutive transfers this field defines the delay between two consecutive transfers with the same perip heral without removing the chip select. the delay is always inserted after each transfer and before removing the chip select if needed. when dlybct equals zero, no delay between consecutive transf ers is inserted and the clock keeps its duty cycle over the character transfers. otherwise, the following equat ion determines the delay: if fdiv is 0: if fdiv is 1: n = 32 delay before spck dlybs mck ------------------ - = delay before spck ndlybs mck ---------------------------- - = delay between consecutive transfers 32 dlybct mck ------------------------------------ scbr 2 mck ---------------- - + = delay between consecutive transfers 32 n dlybct mck ---------------------------------------------- - nscbr 2 mck ------------------------- + =
309 32015a?avr32?02/07 AT32AP7001 22. two-wire interface (twi) rev: 1.8.0.0 22.1 features ? compatible with philips? i 2 c protocol ? one, two or three bytes for slave address ? sequential read/write operations 22.2 description the two-wire interface (twi) interconnects components on a unique two-wire bus, made up of one clock line and one data line with speeds of up to 400 kbits per second, based on a byte-ori- ented transfer format. it can be used with any atme l two-wire bus serial eeprom. the twi is programmable as a master with sequential or single-byte access. a configurable baud rate gen- erator permits the output data rate to be adapted to a wide range of core clock frequencies. 22.3 block diagram figure 22-1. block diagram 22.4 application block diagram figure 22-2. application block diagram peripheral bus bridge power manager mck two-wire interface pio interrupt controller twi interrupt twck twd host with twi interface twd twck at24lc16 u1 at24lc16 u2 lcd controller u3 slave 1 slave 2 slave 3 rr vdd
310 32015a?avr32?02/07 AT32AP7001 22.4.1 i/o lines description 22.5 product dependencies 22.5.1 i/o lines both twd and twck are bi-directional lines, connected to a positive supply voltage via a cur- rent source or pull-up resistor (see figure 22-2 on page 309 ). when the bus is free, both lines are high. the output stages of devices connected to the bus must have an open-drain or open- collector to perform the wired-and function. twd and twck pins may be multiplexed with pi o lines. to enable the twi, the programmer must program the pio controller to dedicate twd and twck as peripheral lines. 22.5.2 power management the twi clock is generated by the power manager. before using the twi, the programmer must ensure that the twi clock is enabled in the power manager. in the twi description, master clock (mck) is the clock of the peripheral bus to which the twi is connected. 22.5.3 interrupt the twi interface has an interrupt line connected to the interrupt controller. in order to handle interrupts, the interrupt controller must be programmed before configuring the twi. table 22-1. i/o lines description pin name pin description type twd two-wire serial data input/output twck two-wire serial clock input/output
311 32015a?avr32?02/07 AT32AP7001 22.6 functional description 22.6.1 transfer format the data put on the twd line must be 8 bits long. data is transferred msb first; each byte must be followed by an acknowledgement. the number of bytes per transfer is unlimited (see figure 22-4 on page 311 ). each transfer begins with a start condition and terminates with a stop condition (see figure 22-3 on page 311 ). ? a high-to-low transition on the twd line while twck is high defines the start condition. ? a low-to-high transition on the twd line while twck is high defines a stop condition. figure 22-3. start and stop conditions figure 22-4. transfer format 22.6.2 modes of operation the twi has two modes of operation: ? master transmitter mode ? master receiver mode the twi control register (cr) allows configurat ion of the interface in master mode. in this mode, it generates the clock according to the value programmed in the clock waveform gener- ator register (cwgr). this register defines the twck signal completely, enabling the interface to be adapted to a wide range of clocks. 22.6.3 transmitting data after the master initiates a start condition, it sends a 7-bit slave address, configured in the mas- ter mode register (dadr in mmr), to notify th e slave device. the bit following the slave address indicates the transfer direction (write or read). if this bit is 0, it indicates a write operation (trans- mit operation). if the bit is 1, it indicate s a request for data read (receive operation). the twi transfers require the slave to acknowledge each received byte. during the acknowl- edge clock pulse, the master releases the data line (high), enabling the slave to pull it down in order to generate the acknowledge. the master polls the data line during this clock pulse and sets the nak bit in the status register if the slave does not acknowledge the byte. as with the twd twck start stop twd twck start address r/w ack data ack data ack stop
312 32015a?avr32?02/07 AT32AP7001 other status bits, an interrupt can be generated if enabled in the interrupt enable register (ier). after writing in the transmit-holding register (thr ), setting the start bit in the control register starts the transmission. the data is shifted in the internal shifter and when an acknowledge is detected, the txrdy bit is set un til a new write in the thr (see figure 22-6 below). the master generates a stop condition to end the transfer. the read sequence begins by setting the start bit. when the rxrdy bit is set in the status register, a character has been received in the receive-holding register (rhr). the rxrdy bit is reset when reading the rhr. the twi interface performs various transfer formats (7-bit slave address, 10-bit slave address). the three internal address bytes are configurable through the master mode register (mmr). if the slave device supports only a 7-bit address, iadrsz must be set to 0. for a slave address higher than 7 bits, the user must configure the address size (iadrsz ) and set the other slave address bits in the internal address register (iadr). figure 22-5. master write with one, two or three bytes internal address and one data byte figure 22-6. master write with one byte internal address and multiple data bytes figure 22-7. master read with one, two or three bytes internal address and one data byte s dadr w a iadr(23:16) a iadr(15:8) a iadr(7:0) a data a p s dadr w a iadr(15:8) a iadr(7:0) a p data a a iadr(7:0) a p data a s dadr w twd three bytes internal address two bytes internal address one byte internal address twd twd a iadr(7:0) a data a s dadr w data a p data a txcomp txrdy write thr write thr write thr write thr twd s dadr w a iadr(23:16) a iadr(15:8) a iadr(7:0) a s dadr w a iadr(15:8) a iadr(7:0) a a iadr(7:0) a s dadr w data n p s dadr r a s dadr r a data n p s dadr r a data n p twd twd twd three bytes internal address two bytes internal address one byte internal address
313 32015a?avr32?02/07 AT32AP7001 figure 22-8. master read with one byte internal address and multiple data bytes ?s = start ?p = stop ?w = write ? r = read ? a = acknowledge ? n = not acknowledge ? dadr= device address ? iadr = internal address figure 22-9 below shows a byte write to an atmel at24lc512 eeprom. this demonstrates the use of internal addresses to access the device. figure 22-9. internal address usage a iadr(7:0) a s dadr w s dadr r a data a data n p txcomp write start bit rxrdy write stop bit read rhr read rhr twd s t a r t m s b device address 0 l s b r / w a c k m s b w r i t e a c k a c k l s b a c k first word address second word address data s t o p
314 32015a?avr32?02/07 AT32AP7001 22.6.4 read/write flowcharts the following flowcharts shown in figure 22-10 on page 314 and in figure 22-11 on page 315 give examples for read and write operations in master mode. a polling or interrupt method can be used to check the status bits. the interrupt method requires that the interrupt enable register (ier) be configured first. figure 22-10. twi write in master mode set twi clock: cwgr = clock set the control register: - master enable cr = msen set the master mode register: - device slave address - internal address size - transfer direction bit write ==> bit mread = 0 internal address size = 0? load transmit register thr = data to send read status register txrdy = 0? data to send? read status register txcomp = 0? end start set theinternal address iadr = address ye s thr = data to send ye s ye s ye s
315 32015a?avr32?02/07 AT32AP7001 figure 22-11. twi read in master mode set twi clock: cwgr = clock set the control register: - master enable cr = msen set the master mode register: - device slave address - internal address size - transfer direction bit read ==> bit mread = 0 internal address size = 0? start the transfer cr = start stop the transfer cr = stop read status register rxrdy = 0? data to read? read status register txcomp = 0? end start set the internal address iadr = address ye s ye s ye s ye s read rhr
316 32015a?avr32?02/07 AT32AP7001 22.7 twi user interface 22.7.1 register mapping table 22-2. two-wire interface (twi) user interface offset register name access reset value 0x0000 control register cr write-only n/a 0x0004 master mode register mmr read/write 0x0000 0x0008 reserved - - - 0x000c internal address register iadr read/write 0x0000 0x0010 clock waveform generator register cwgr read/write 0x0000 0x0020 status register sr read-only 0x0008 0x0024 interrupt enable register ier write-only n/a 0x0028 interrupt disable register idr write-only n/a 0x002c interrupt mask register imr read-only 0x0000 0x0030 receive holding register rhr read-only 0x0000 0x0034 transmit holding register thr read/write 0x0000
317 32015a?avr32?02/07 AT32AP7001 22.7.2 twi control register register name :cr access type: write-only ? start: send a start condition 0 = no effect. 1 = a frame beginning with a start bit is transmitted according to the settings in the mode register. this action is necessary when the twi peripheral wants to read data from a slave. when configured in master mode with a write operation, a frame is sent with the mode register as soon as the user writes a character in the holding register. ? stop: send a stop condition 0 = no effect. 1 = stop condition is sent just after completing the current byte transmission in master read or write mode. in single data byte master read or write, the start and stop must both be set. in multiple data bytes master read or write, the stop must be set before ack/nack bit transmission. in master read mode, if a nack bit is received, the stop is automatically performed. in multiple data write operation, when both thr and shift register are empty, a stop condition is automatically sent. ? msen: twi master transfer enabled 0 = no effect. 1 = if msdis = 0, the master data transfer is enabled. ? msdis: twi master transfer disabled 0 = no effect. 1 = the master data transfer is disabled, all pending data is tr ansmitted. the shifter and holding characters (if they contain data) are transmitted in case of write operation. in read operation, the character being transferred must be completely received before disabling. ? swrst: software reset 0 = no effect. 1 = equivalent to a system reset. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 swrst ? ? ? msdis msen stop start
318 32015a?avr32?02/07 AT32AP7001 22.7.3 twi master mode register register name :mmr address type : read/write ? iadrsz: internal device address size ? mread: master read direction 0 = master write direction. 1 = master read direction. ? dadr: device address the device address is used in master mode to access slave devices in read or write mode. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ?dadr 15 14 13 12 11 10 9 8 ???mread?? iadrsz 76543210 ???????? iadrsz[9:8] 0 0 no internal device address (byte command protocol) 0 1 one-byte internal device address 1 0 two-byte internal device address 1 1 three-byte internal device address
319 32015a?avr32?02/07 AT32AP7001 22.7.4 twi internal address register register name :iadr access type : read/write ? iadr: internal address 0, 1, 2 or 3 bytes depending on iadrsz. ? low significant byte address in 10-bit mode addresses. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 iadr 15 14 13 12 11 10 9 8 iadr 76543210 iadr
320 32015a?avr32?02/07 AT32AP7001 22.7.5 twi clock waveform generator register register name :cwgr access type : read/write ? cldiv: clock low divider the scl low period is defined as follows: ? chdiv: clock high divider the scl high period is defined as follows: ? ckdiv: clock divider the ckdiv is used to increase both scl high and low periods. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? ckdiv 15 14 13 12 11 10 9 8 chdiv 76543210 cldiv t low cldiv ( 2 ckdiv () 3 ) + t mck = t high chdiv ( 2 ckdiv () 3 ) + t mck =
321 32015a?avr32?02/07 AT32AP7001 22.7.6 twi status register register name :sr access type : read-only ? txcomp: transmission completed 0 = in master, during the length of the current frame. in slave, from start received to stop received. 1 = when both holding and shift registers are empty and stop condition has been sent (in master), or when msen is set (enable twi). ? rxrdy: receive hold ing register ready 0 = no character has been received since the last rhr read operation. 1 = a byte has been received in therhr since the last read. ? txrdy: transmit holding register ready 0 = the transmit holding register has not been transferred into shift register. set to 0 when writing into thr register. 1 = as soon as data byte is transferred from thr to internal shifter or if a nack error is detected, txrdy is set at the same time as txcomp and nack. txrdy is also set when msen is set (enable twi). ? nack: not acknowledged 0 = each data byte has been correctly received by the far-end side twi slave component. 1 = a data byte has not been acknowledged by the slave compo nent. set at the same time as txcomp. reset after read. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????nack 76543210 ?????txrdyrxrdytxcomp
322 32015a?avr32?02/07 AT32AP7001 22.7.7 twi interrupt enable register register name :ier access type: write-only ? txcomp: transmission completed ? rxrdy: receive hold ing register ready ? txrdy: transmit holding register ready ? nack: not acknowledge 0 = no effect. 1 = enables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????nack 76543210 ?????txrdyrxrdytxcomp
323 32015a?avr32?02/07 AT32AP7001 22.7.8 twi interrupt disable register register name :idr access type: write-only ? txcomp: transmission completed ? rxrdy: receive hold ing register ready ? txrdy: transmit holding register ready ? nack: not acknowledge 0 = no effect. 1 = disables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????nack 76543210 ?????txrdyrxrdytxcomp
324 32015a?avr32?02/07 AT32AP7001 22.7.9 twi interrupt mask register register name :imr access type : read-only ? txcomp: transmission completed ? rxrdy: receive hold ing register ready ? txrdy: transmit holding register ready ? nack: not acknowledge 0 = the corresponding interrupt is disabled. 1 = the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????nack 76543210 ?????txrdyrxrdytxcomp
325 32015a?avr32?02/07 AT32AP7001 22.7.10 twi receive holding register register name : rhr access type : read-only ? rxdata: master or slave receive holding data 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 rxdata
326 32015a?avr32?02/07 AT32AP7001 22.7.11 twi transmit holding register register name :thr access type: read/write ? txdata: master or slave transmit holding data 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 txdata
327 32015a?avr32?02/07 AT32AP7001 23. ps/2 module (psif) rev: 1.0.0.0 23.1 features ? ps/2 host ? receive and transmit capability ? parity generation and error detection ? overrun error detection 23.2 description the ps/2 module provides host functionality allowing the mcu to interface ps/2 devices such as keyboard and mice. the module is capable of both host-to-device and device-to-host communication. 23.3 product dependencies 23.3.1 i/o lines the ps/2 may be multiplexed with pio lines. the programmer must first program the pio con- troller to give control of the pins to the ps/2 module. 23.3.2 power management the clock for the ps/2 module is generated by the power manager. the programmer must ensure that the ps/2 clock is enabled in the power manager before using the ps/2 module. 23.3.3 interrupt the ps/2 module has an interrupt line connected to the interrupt controller. handling the ps/2 interrupt requires programming the interrupt controller before configuring the ps/2 module. 23.4 the ps/2 protocol the ps/2 protocol is a bidirectional synchronous serial communication protocol. it connects a single master - referred to as the ?host? - to a single slave - referred to as the ?device?. communi- cation is done through two lines called ?data? and ?clock?. both of these must be open-drain or open-collector with a pullup resistor to perform a wired-and function. when the bus is idle, both lines are high. the device always generates the clock signal, but the host may pull the clock low to inhibit trans- fers. the clock frequency is in the range 10-16.7 khz. both the host and the slave may initiate a transfer, but the host has ultimate control of the bus. data are transmitted one byte at a time in a frame consisting of 11-12 bits. the transfer format is described in detail below. 23.4.1 device to host communication the device can only initiate a transfer when the bus is idle. if the host at any time pulls the clock low, the device must stop transferring data and prepare to receive data from the host. the device transmits data using a 11-bit frame. t he device writes a bit on the data line when the clock is high, and the host reads the bit when the clock is low. the format of the frame is:
328 32015a?avr32?02/07 AT32AP7001 ? 1 start bit - always 0. ? 8 data bits, least significant bit first. ? 1 parity bit - odd parity. ? 1 stop bit - always 1. figure 23-1. device to host transfer 23.4.2 host to device communication because the device always generates the clock, host to device communication is done differ- ently than device to host communication. ? the host starts by inhibiting communicati on by pulling clock low for a minimum of 100 microseconds. ? then applies a ?request-to-send? by releasing clock and pulling data low. the device must check for this state at least ev ery 10 milliseconds. once it detects a request-to- send, it must start generating the clock and receive one frame of data. the host writes a data bit when the clock is low, and the device reads the bit when the clock is high. the format of the frame is: ? 1 start bit - always 0. ? 8 data bits - least significant bit first. ? 1 parity bit - odd parity ? 1 stop bit - always one. ? 1 acknowledge bit - the device acknowledges by pulling data low. start bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 7 stop bit 6 c lock d ata parity
329 32015a?avr32?02/07 AT32AP7001 figure 23-2. host to device transfer 23.5 functional description 23.5.1 prescaler for all data transfers on the ps/2 bus, the dev ice is responsible for generating the clock and thus controlling the timing of th e communications. when a host wa nts to initiate a transfer how- ever, it needs to pull the clock line low for a given time (minimum 100s). a clock prescaler controls the timing of the transfer request pulse. before initiating host to device transfers, the programmer must write psr (prescale register). this value determines the length of the ?transfer request? pulse and is found by: prscv = pulse length * ps/2 module frequency according to the ps/2 specifications, the pulse length should be at least 100s. the ps/2 mod- ule frequency is the frequency of the peripheral bus to which the module is connected. 23.5.2 receiving data the receiver is enabled by writing the rxen bi t in cr (control register) to ?1?. when enabled, the receiver will continuously receiv e data transmitted by the device . the data is stored in rhr (receive holding register). when a byte has been received, the rxrdy bit in sr (status reg- ister) is set. for each received byte, the parity is calculated. if it doesn?t match the parity bit received from the device, the parity bit in sr is set. the received byte should then be discarded. if a received byte in rhr is not read before a new byte has been received, the overrun bit - ovrun in sr is set. the new data is stored in rhr overwriting the previously received byte. 23.5.3 transmitting data the transmitter is enabled by writing the txen bit in cr to ?1?. when enabled, a data transfer to the device will be started by wr iting the transmit data to thr (transmit holding register). any ongoing transfer from the device will be aborted. start bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 stop bit 6 inhibit ack clock data host clock host data device clock device data bit 7 parity
330 32015a?avr32?02/07 AT32AP7001 when the data written to thr has been transmitted to the device, the txrdy bit in sr will be set and a new value can be loaded into thr. at the end of the transfer, the device should acknowledge the transfer by pulling the data line low for one cycle. if an acknowledge is not detected, the nack bit in sr will be set. if the device fails to a cknowledge the frame, th e nack bit in sr will be set. the software is responsible for any retries. all transfers from host to device are started by the host pulling the clock line low for at least 100s. the programmer must ensure that the prescaler is programmed to generate correct pulse length. 23.5.4 interrupts the ps/2 module can be configured to signal an interrupt when one of the bits in sr is set. the interrupt is enabled by writing to ier (interrupt enable register) and disabled by writing to idr (interrupt disable register). the current setting of an interrupt line can be seen by reading imr (interrupt mask register). 23.6 user interface offset register register name access reset 0x000 ps/2 control register 0 cr0 write-only - 0x004 ps/2 receive holding register 0 rhr0 read-only 0x0 0x008 ps/2 transmit holding register 0 thr0 write-only - 0x00c reserved - - - 0x010 ps/2 status register 0 sr0 read-only 0x0 0x014 ps/2 interrupt enable register 0 ier0 write-only - 0x018 ps/2 interrupt disable register 0 idr0 write-only - 0x01c ps/2 interrupt mask register 0 imr0 read-only 0x0 0x020 ps/2 prescale register 0 psr0 write-only 0x0 0x100 ps/2 control register 1 cr1 write-only - 0x104 ps/2 receive holding register 1 rhr1 read-only 0x0 0x108 ps/2 transmit holding register 1 thr1 write-only - 0x10c reserved - - - 0x110 ps/2 status register 1 sr1 read-only 0x0 0x114 ps/2 interrupt enable register 1 ier1 write-only - 0x118 ps/2 interrupt disable register 1 idr1 write-only - 0x11c ps/2 interrupt mask register 1 imr1 read-only 0x0 0x120 ps/2 prescale register 1 psr1 write-only 0x0
331 32015a?avr32?02/07 AT32AP7001 23.6.1 ps/2 control register name: cr0, cr1 access type: write-only ? swrst: software reset writing this strobe causes a reset of the ps/2 interface module. data shift registers are cleared and configuration registers a re reset to default values. ? txdis: transmitter disable 0: no effect. 1: disables the transmitter. ? txen: transmitter enable 0: no effect. 1: enables the transmitter if txdis=0. ? rxdis: receiver disable 0: no effect. 1: disables the receiver. ? rxen: receiver enable 0: no effect. 1: enables the receiver if rxdis=0. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 swrst - - - - - txdis txen 76543210 ------rxdisrxen
332 32015a?avr32?02/07 AT32AP7001 23.6.2 ps/2 receive holding register name: rhr0, rhr1 access type: read-only ? rxdata: receive data data received from the device. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 rxdata
333 32015a?avr32?02/07 AT32AP7001 23.6.3 ps/2 transmit holding register name: thr0, thr1 access type: write-only ? txdata: transmit data ? data to be transmitted to the device. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 txdata
334 32015a?avr32?02/07 AT32AP7001 23.6.4 ps/2 status register name: sr0, sr1 access type: read-only ? parity: 0: no parity errors detected on incoming data since last read of sr. 1: at least one parity error detected on incoming data since last read of sr. ? nack: not acknowledge 0: all transmissions has been properly acknowle dged by the device since last read of sr. 1: at least one transmission was not properly acknowledged by the device since last read of sr. ? ovrun: overrun 0: no receive overrun has occured since the last read of sr. 1: at least one receive overrun condition has occured since the last read of sr. ? rxrdy: receiver ready 0: rhr is empty. 1: rhr contains valid data received from the device. ? txempty: transmitter empty 0: data remains in thr or is currently being transmitted from the shift register. 1: both thr and the sh ift register are empty. ? txrdy: transmitter ready 0: data has been loaded in thr and is waiting to be loaded into the shift register. 1: thr is empty. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------paritynack 76543210 - - ovrun rxrdy - - txempty txrdy
335 32015a?avr32?02/07 AT32AP7001 23.6.5 ps/2 interrupt enable register name: ier0, ier1 access type: write-only ? parity: parity interrupt enable ? nack: not acknowledge interrupt enable ? ovrun: overrun interrupt enable ? rxrdy: overrun interrupt enable ? txempty: overrun interrupt enable ? txrdy: overrun interrupt enable 0: no effect. 1: enables the corresponding interrupt. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------paritynack 76543210 - - ovrun rxrdy - - txempty txrdy
336 32015a?avr32?02/07 AT32AP7001 ? 23.6.6 ps/2 interrupt disable register name: idr0, idr1 access type: write-only ? parity: parity interrupt disable ? nack: not acknowledge interrupt disable ? ovrun: overrun interrupt disable ? rxrdy: overrun interrupt disable ? txempty: overrun interrupt disable ? txrdy: overrun interrupt disable 0: no effect. 1: disables the corresponding interrupt. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------paritynack 76543210 - - ovrun rxrdy - - txempty txrdy
337 32015a?avr32?02/07 AT32AP7001 23.6.7 ps/2 interrupt mask register name: imr0, imr1 access type: read-only ? parity: parity interrupt mask ? nack: not acknowledge interrupt mask ? ovrun: overrun interrupt mask ? rxrdy: overrun interrupt mask ? txempty: overrun interrupt mask ? txrdy: overrun interrupt mask 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 ------paritynack 76543210 - - ovrun rxrdy - - txempty txrdy
338 32015a?avr32?02/07 AT32AP7001 23.6.8 ps/2 prescale register name: psr0, psr1 access type: read/write ? prscv: prescale value 31 30 29 28 27 26 25 24 -------- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 - - - prscv 76543210 prscv
339 32015a?avr32?02/07 AT32AP7001 24. synchronous serial controller (ssc) rev: 2.2.0.0 24.1 features ? provides serial synchronous communication links used in audio and telecom applications ? contains an independent receiver and transmitter an d a common clock divider ? interfaced with two pdc channels (dma access) to reduce processor overhead ? offers a configurable frame sync and data length ? receiver and transmitter can be programmed to st art automatically or on detection of different events on the frame sync signal ? receiver and transmitter includ e a data signal, a cl ock signal and a frame synchronization signal 24.2 description the atmel synchronous serial controller (ssc ) provides a synchronous communication link with external devices. it supports many serial synchronous communication protocols generally used in audio and telecom applications such as i2s, short frame sync, long frame sync, etc. the ssc contains an independent receiver and transmitter and a common clock divider. the receiver and the transmitter each interface with three signals: the td/rd signal for data, the tk/rk signal for the clock and the tf/rf signal for the frame sync. the transfers can be pro- grammed to start automatically or on different events detected on the frame sync signal. the ssc?s high-level of programmability and its two dedicated pdc channels of up to 32 bits permit a continuous high bit rate data transfer without processor intervention. featuring connection to two pdc channels, the ssc permits interfacing with low processor overhead to the following: ? codec?s in master or slave mode ? dac through dedicated serial interface, particularly i2s ? magnetic card reader
340 32015a?avr32?02/07 AT32AP7001 24.3 block diagram figure 24-1. block diagram 24.4 application block diagram figure 24-2. application block diagram ssc interface pio pdc peripheral bus bridge mck high speed bus peripheral bus tf tk td rf rk rd interrupt control ssc interrupt power manager interrupt management power management test management ssc serial audio os or rtos driver codec frame management line interface time slot management
341 32015a?avr32?02/07 AT32AP7001 24.5 pin name list 24.6 product dependencies 24.6.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with pio lines. before using the ssc receiver, the pio contro ller must be configured to dedicate the ssc receiver i/o lines to the ssc peripheral mode. before using the ssc transmitter, the pio controller must be configured to dedicate the ssc transmitter i/o lines to the ssc peripheral mode. 24.6.2 power management the ssc clock is generated by the power manager. before using the ssc, the programmer must ensure that the ssc clock is enabled in the power manager. in the ssc description, master clock (mck) is t he bus clock of the peripheral bus to which the ssc is connected. 24.6.3 interrupt the ssc interface has an interrupt line connected to the interrupt controller. handling interrupts requires programming the interrupt controller before configuring the ssc. all ssc interrupts can be enabled/disabled configur ing the ssc interrupt mask register. each pending and unmasked ssc interrupt will assert the ssc interrupt line. the ssc interrupt ser- vice routine can get the interrupt origin by reading the ssc interrupt status register. 24.7 functional description this chapter contains the functional description of the following: ssc functional block, clock management, data format, start, transmitter, receiver and frame sync. the receiver and transmitter operate separately. however, they can work synchronously by pro- gramming the receiver to use the transmit clock and/or to start a data transfer when transmission starts. alternatively, this can be done by programming the transmitter to use the receive clock and/or to start a data transfer when reception starts. the transmitter and the receiver can be pro- grammed to operate with the clock signals provided on either the tk or rk pins. this allows the ssc to support many slave-mode data transfer s. the maximum clock speed allowed on the tk and rk pins is the master clock divided by 2. table 24-1. i/o lines description pin name pin description type rf receiver frame synchro input/output rk receiver clock input/output rd receiver data input tf transmitter frame synchro input/output tk transmitter clock input/output td transmitter data output
342 32015a?avr32?02/07 AT32AP7001 figure 24-3. ssc functional block diagram 24.7.1 clock management the transmitter clock can be generated by: ? an external clock received on the tk i/o pad ? the receiver clock ? the internal clock divider the receiver clock can be generated by: ? an external clock received on the rk i/o pad ? the transmitter clock ? the internal clock divider furthermore, the transmitter block can generate an external clock on the tk i/o pad, and the receiver block can generate an external clock on the rk i/o pad. this allows the ssc to support many master and slave mode data transfers. interrupt control interrupt controller user interface peripheral bus mck receive clock controller start selector tx clock rk input rf tf clock output controller frame sync controller transmit clock controller transmit shift register start selector transmit sync holding register transmit holding register load shift rx clock tx clock tk input tf tx pdc rf rd rf rk clock output controller frame sync controller receive shift register receive sync holding register receive holding register load shift td tf tk rx clock rx pdc receiver pdc transmitter clock divider
343 32015a?avr32?02/07 AT32AP7001 24.7.1.1 clock divider figure 24-4. divided clock block diagram the master clock divider is determined by the 12-bit field div counter and comparator (so its maximal value is 4095) in the clock mode regist er cmr, allowing a master clock division by up to 8190. the divided clock is provided to both the receiver and transmitter. when this field is programmed to 0, the clock divider is not used and remains inactive. when div is set to a value equal to or greater than 1, the divided clock has a frequency of mas- ter clock divided by 2 times div. each level of the divided clock has a duration of the master clock multiplied by div. this ensures a 50 % duty cycle for the divided clock regardless of whether the div value is even or odd. figure 24-5. divided clock generation 24.7.1.2 transmitter clock management the transmitter clock is generated from the receiver clock or the divider clock or an external clock scanned on the tk i/o pad. the transmitter clock is selected by the cks field in tcmr (transmit clock mode register). transmit cl ock can be inverted independently by the cki bits in tcmr. table 24-2. maximum minimum mck / 2 mck / 8190 mck divided cloc k clock divider / 2 12-bit counter ssc_cmr master clock divided clock div = 1 master clock divided clock div = 3 divided clock frequency = mck/2 divided clock frequency = mck/6
344 32015a?avr32?02/07 AT32AP7001 the transmitter can also drive the tk i/o pad cont inuously or be limited to the actual data trans- fer. the clock output is configured by the tcmr register. the transmit clock inversion (cki) bits have no effect on the clock outputs. programming the tcmr register to select tk pin (cks field) and at the same time continuous transmit clock (cko field) might lead to unpredictable results. figure 24-6. transmitter clock management 24.7.1.3 receiver clock management the receiver clock is generated from the transmitter clock or the divider clock or an external clock scanned on the rk i/o pad. the receive clock is selected by the cks field in rcmr (receive clock mode register). receive clocks can be inverted independently by the cki bits in rcmr. the receiver can also drive the rk i/o pad continuo usly or be limited to the actual data transfer. the clock output is configured by the rcmr register. the receive clock inversion (cki) bits have no effect on the clock outputs. programming the rcmr register to select rk pin (cks field) and at the same time continuous receive clock (cko field) can lead to unpredictable results. tk (pin) receiver clock divider clock cks cko data transfer cki ckg transmitter clock clock output mux tri_state controller tri-state controller inv mux
345 32015a?avr32?02/07 AT32AP7001 figure 24-7. receiver clock management 24.7.1.4 serial clock ratio considerations the transmitter and the receiver can be programmed to operate with the clock signals provided on either the tk or rk pins. this allows the ssc to support many slave-mode data transfers. in this case, the maximum clock speed allowed on the rk pin is: ? master clock divided by 2 if receiver frame synchro is input ? master clock divided by 3 if receiver frame synchro is output in addition, the maximum clock speed allowed on the tk pin is: ? master clock divided by 6 if transmit frame synchro is input ? master clock divided by 2 if transmit frame synchro is output 24.7.2 transmitter operations a transmitted frame is triggered by a start event and can be followed by synchronization data before data transmission. the start event is configured by setting the transmit clock mode register (tcmr). see section ?24.7.4? on page 347. the frame synchronization is configured setting the transmit frame mode register (tfmr). see section ?24.7.5? on page 349. to transmit data, the transmitter uses a shift re gister clocked by the transmitter clock signal and the start mode selected in the tcmr. data is written by the application to the thr register then transferred to the shift register according to the data format selected. when both the thr and the transmit shift register are empty, the status flag txempty is set in sr. when the transmit holding register is transferred in the transmit shift register, the status flag txrdy is set in sr and additional data can be loaded in the holding register. rk (pin) transmitter clock divider clock cks cko data transfer cki ckg receiver clock clock output mux tri-state controller tri-state controller inv mux
346 32015a?avr32?02/07 AT32AP7001 figure 24-8. transmitter block diagram 24.7.3 receiver operations a received frame is triggered by a start event and can be followed by synchronization data before data transmission. the start event is configured setting the receive clock mode register (rcmr). see section ?24.7.4? on page 347. the frame synchronization is configured setting the receive frame mode register (rfmr). see section ?24.7.5? on page 349. the receiver uses a shift register clocked by the receiver clock signal and the start mode selected in the rcmr. the data is transferred from the shift register depending on the data for- mat selected. when the receiver shift register is full, the ssc transfers this data in the holding register, the sta- tus flag rxrdy is set in sr and the data can be read in the receiver holding register. if another transfer occurs before read of the rhr register, the status flag overun is set in sr and the receiver shift register is tr ansferred in the rhr register. transmit shift register start selector ssc_tshr ssc_thr transmitter clock td ssc_tfmr.fslen ssc_tfmr.datlen ssc_cr.txen ssc_cr.txdis ssc_tcmr.sttdly ssc_tfmr.fsden ssc_tfmr.datnb ssc_sr.txen ssc_tfmr.datdef ssc_tfmr.msbf ssc_tcmr.sttdly ssc_tfmr.fsden 0 1 1 0 rf tf
347 32015a?avr32?02/07 AT32AP7001 figure 24-9. receiver block diagram 24.7.4 start the transmitter and receiver can both be programmed to start their operations when an event occurs, respectively in the transmit start selection (start) field of tcmr and in the receive start selection (start) field of rcmr. under the following conditions the start event is independently programmable: ? continuous. in this case, the transmission starts as soon as a word is written in thr and the reception starts as soon as the receiver is enabled. ? synchronously with the transmitter/receiver ? on detection of a falling/rising edge on tf/rf ? on detection of a low level/high level on tf/rf ? on detection of a level change or an edge on tf/rf a start can be programmed in the same manner on either side of the transmit/receive clock register (rcmr/tcmr). thus, the start coul d be on tf (transmit) or rf (receive). moreover, the receiver can start when data is detected in the bit stream with the compare functions. detection on tf/rf input/output is done by the field fsos of the transmit/receive frame mode register (tfmr/rfmr). receive shift register start selector ssc_rhr ssc_rshr receiver clock rd ssc_rfmr.fslen ssc_rfmr.datlen rf ssc_cr.rxen ssc_cr.rxdis ssc_sr.rxen ssc_rfmr.msbf ssc_rcmr.sttdly ssc_rfmr.datnb tf
348 32015a?avr32?02/07 AT32AP7001 figure 24-10. transmit start mode figure 24-11. receive pulse/ed ge start modes x tk tf (input) td (output) td (output) td (output) td (output) td (output) td (output) xbob1 x bo b1 bo b1 bo b1 bo b1 bo b1 bo b1 b1 bo x x x sttdly sttdly sttdly sttdly sttdly sttdly start = falling edge on tf start = rising edge on tf start = low level on tf start = high level on tf start = any edge on tf start = level change on tf x rk rf (input) rd (input) rd (input) rd (input) rd (input) rd (input) rd (input) xbob1 x bo b1 bo b1 bo b1 bo b1 bo b1 bo b1 b1 bo x x x sttdly sttdly sttdly sttdly sttdly sttdly start = falling edge on rf start = rising edge on rf start = low level on rf start = high level on rf start = any edge on rf start = level change on rf
349 32015a?avr32?02/07 AT32AP7001 24.7.5 frame sync the transmitter and receiver frame sync pins, tf and rf, can be programmed to generate different kinds of frame synchron ization signals. the frame sync output selection (fsos) field in the receive frame mode regi ster (rfmr) and in the transmit frame mode register (tfmr) are used to select the required waveform. ? programmable low or high levels during data transfer are supported. ? programmable high levels before the start of data transfers or toggling are also supported. if a pulse waveform is selected, the frame sync length (fslen) field in rfmr and tfmr pro- grams the length of the pulse, from 1 bit time up to 16 bit time. the periodicity of the receive and transmit frame sync pulse output can be programmed through the period divider selection (period) field in rcmr and tcmr. 24.7.5.1 frame sync data frame sync data transmits or receives a specific tag during the frame sync signal. during the frame sync signal, the receiver can sample the rd line and store the data in the receive sync holding register and the transmitter can transfer transmit sync holding register in the shifter register. the data length to be sampled/shifted out during the frame sync signal is programmed by the fslen field in rfmr/tfmr. concerning the receive frame sync data operation, if the frame sync length is equal to or lower than the delay between the start event and the actual data reception, the data sampling operation is performed in the re ceive sync holding register thr ough the receive shift register. the transmit frame sync operation is performed by the transmitter only if the bit frame sync data enable (fsden) in tfmr is set. if the fr ame sync length is equal to or lower than the delay between the start event and the actual dat a transmission, the normal transmission has pri- ority and the data contained in the transmit sync holding register is transferred in the transmit register, then shifted out. 24.7.5.2 frame sync edge detection the frame sync edge detection is programmed by the fsedge field in rfmr/tfmr. this sets the corresponding flags rxsyn/txsyn in the ssc status register (sr) on frame synchro edge detection (signals rf/tf).
350 32015a?avr32?02/07 AT32AP7001 24.7.6 receive compare modes figure 24-12. receive compare modes 24.7.6.1 compare functions compare 0 can be one start event of the receiver. in this case, the receiver compares at each new sample the last fslen bits received at the fslen lower bit of the data contained in the compare 0 register (rc0r). when this start ev ent is selected, the user can program the receiver to start a new data transfer either by writing a new compare 0, or by receiving continu- ously until compare 1 occurs. this selecti on is done with the bit (stop) in rcmr. 24.7.7 data format the data framing format of both the transmitter and the receiver are programmable through the transmitter frame mode register (tfmr) and the receiver frame mode register (rfmr). in either case, the user can independently select: ? the event that starts the data transfer (start) ? the delay in number of bit periods between the start event and the first data bit ( sttdly ) ? the length of the data (datlen) ? the number of data to be transferred for each start event (datnb). ? the length of synchronization transferred for each start event (fslen) ? the bit sense: most or lowest significant bit first (msbf). additionally, the transmitter can be used to tr ansfer synchronization and select the level driven on the td pin while not in data transfer operation. this is done respectively by the frame sync data enable (fsden) and by the data default value (datdef) bits in tfmr. cmp0 cmp3 cmp2 cmp1 ignored b0 b2 b1 start rk rd (input) fslen up to 16 bits (4 in this example) stdly datlen
351 32015a?avr32?02/07 AT32AP7001 figure 24-13. transmit and receive frame format in edge/pulse start modes note: 1. example of input on falling edge of tf/rf. table 24-3. data frame registers transmitter receiver field length comment tfmr rfmr datlen up to 32 size of word tfmr rfmr datnb up to 16 number of words transmitted in frame tfmr rfmr msbf most significant bit first tfmr rfmr fslen up to 16 size of synchro data register tfmr datdef 0 or 1 data default value ended tfmr fsden enable send tshr tcmr rcmr period up to 512 frame size tcmr rcmr sttdly up to 255 size of transmit start delay sync data default sttdly sync data ignored rd default data datlen data data data datlen data data default default ignored sync data sync data fslen tf/rf (1) start start from ssc_tshr from ssc_thr from ssc_thr from ssc_thr from ssc_thr to ssc_rhr to ssc_rhr to ssc_rshr td (if fsden = 0) td (if fsden = 1) datnb period fromdatdef fromdatdef from datdef from datdef
352 32015a?avr32?02/07 AT32AP7001 figure 24-14. transmit frame format in continuous mode note: 1. sttdly is set to 0. in this example, thr is loaded twice. fsden value has no effect on the transmission. syncdata cannot be output in continuous mode. figure 24-15. receive frame format in continuous mode note: 1. sttdly is set to 0. 24.7.8 loop mode the receiver can be programmed to receive transmissions from the transmitter. this is done by setting the loop mode (loop) bit in rfmr. in this case, rd is connected to td, rf is con- nected to tf and rk is connected to tk. 24.7.9 interrupt most bits in sr have a corresponding bit in interrupt management registers. the ssc can be programmed to generate an interrupt when it detects an event. the interrupt is controlled by writing ier (interr upt enable register) and idr (int errupt disable register) these registers enable and disable, respectively, the corresponding interrupt by setting and clearing the corresponding bit in imr (interrupt mask register), which controls the generation of inter- rupts by asserting the ssc interrupt line connected to the interrupt controller. datlen data datlen data default start from ssc_thr from ssc_thr td start: 1. txempty set to 1 2. write into the ssc_thr data datlen data datlen start = enable receiver to ssc_rhr to ssc_rhr rd
353 32015a?avr32?02/07 AT32AP7001 figure 24-16. interrupt block diagram 24.8 ssc application examples the ssc can support several serial communica tion modes used in audio or high speed serial links. some standard applications are shown in t he following figures. all se rial link applications supported by the ssc are not listed here. figure 24-17. audio application block diagram ssc_imr pdc interrupt control ssc interrupt set rxrdy ovrun rxsync receiver transmitter txrdy txempty txsync txbufe endtx rxbuff endrx clear ssc_ier ssc_idr ssc rk rf rd td tf tk clock sck word select ws data sd i2s receiver clock sck word select ws data sd right channel left channel msb msb lsb
354 32015a?avr32?02/07 AT32AP7001 figure 24-18. codec application block diagram figure 24-19. time slot application block diagram ssc rk rf rd td tf tk serial data clock (sclk) frame sync (fsync) serial data out serial data in codec serial data clock (sclk) frame sync (fsync) serial data out serial data in first time slot dstart dend ssc rk rf rd td tf tk sclk fsync data out data in codec first time slot serial data clock (sclk) frame sync (fsync) serial data out serial data in codec second time slot first time slot second time slot dstart dend
355 32015a?avr32?02/07 AT32AP7001 24.9 synchronous serial contro ller (ssc) user interface table 24-4. register mapping offset register register name access reset 0x0 control register cr write ? 0x4 clock mode register cmr read/write 0x0 0x8 reserved ? ? ? 0xc reserved ? ? ? 0x10 receive clock mode register rcmr read/write 0x0 0x14 receive frame mode register rfmr read/write 0x0 0x18 transmit clock mode register tcmr read/write 0x0 0x1c transmit frame mode register tfmr read/write 0x0 0x20 receive holding register rhr read 0x0 0x24 transmit holding register thr write ? 0x28 reserved ? ? ? 0x2c reserved ? ? ? 0x30 receive sync. holding register rshr read 0x0 0x34 transmit sync. holding register tshr read/write 0x0 0x38 receive compare 0 register rc0r read/write 0x0 0x3c receive compare 1 register rc1r read/write 0x0 0x40 status register sr read 0x000000cc 0x44 interrupt enable register ier write ? 0x48 interrupt disable register idr write ? 0x4c interrupt mask register imr read 0x0 0x50-0xfc reserved ? ? ? 0x100- 0x124 reserved for peripheral data controller (pdc) ? ? ?
356 32015a?avr32?02/07 AT32AP7001 24.9.1 ssc control register name: cr access type: write-only ? rxen: receive enable 0: no effect. 1: enables receive if rxdis is not set. ? rxdis: receive disable 0: no effect. 1: disables receive. if a character is currently being re ceived, disables at end of current character reception. ? txen: transmit enable 0: no effect. 1: enables transmit if txdis is not set. ? txdis: transmit disable 0: no effect. 1: disables transmit. if a character is currently being transmitted, disables at end of current character transmission. ? swrst: software reset 0: no effect. 1: performs a software reset. has priority on any other bit in cr. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 swrst?????txdistxen 76543210 ??????rxdisrxen
357 32015a?avr32?02/07 AT32AP7001 24.9.2 ssc clock mode register name: cmr access type: read/write ? div: clock divider 0: the clock divider is not active. any other value: the divided clock equals the master clock divided by 2 times div. the maximum bit rate is mck/2. the minimum bit rate is mck/2 x 4095 = mck/8190. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???? div 76543210 div
358 32015a?avr32?02/07 AT32AP7001 24.9.3 ssc receive clock mode register name: rcmr access type: read/write ? cks: receive clock selection ? cko: receive clock output mode selection ? cki: receive clock inversion 0: the data inputs (data and frame sync signals) are sample d on receive clock falling edge . the frame sync signal out- put is shifted out on receive clock rising edge. 1: the data inputs (data and frame sync signals) are sample d on receive clock rising edge. the frame sync signal out- put is shifted out on receive clock falling edge. cki affects only the receive clock and not the output clock signal. 31 30 29 28 27 26 25 24 period 23 22 21 20 19 18 17 16 sttdly 15 14 13 12 11 10 9 8 ? ? ? stop start 76543210 ckg cki cko cks cks selected receive clock 0x0 divided clock 0x1 tk clock signal 0x2 rk pin 0x3 reserved cko receive clock output mode rk pin 0x0 none input-only 0x1 continuous receive clock output 0x2 receive clock only during data transfers output 0x3-0x7 reserved
359 32015a?avr32?02/07 AT32AP7001 ? ckg: receive clock gating selection ? start: receive start selection ? stop: receive stop selection 0: after completion of a data transfer when starting with a compare 0, the receiver stops the data transfer and waits for a new compare 0. 1: after starting a receive with a compare 0, the receiver operates in a continuous mode until a compare 1 is detected. ? sttdly: receive start delay if sttdly is not 0, a delay of sttdly clock cycles is inserted between the start event and the actual start of reception. when the receiver is programmed to start synchronously with the transmitter, the delay is also applied. note: it is very important that sttdly be set carefully. if sttdly must be set, it should be done in relation to tag (receive sync data) reception. ? period: receive period divider selection this field selects the divider to apply to the selected receive clock in order to generate a new frame sync signal. if 0, no period signal is generated. if not 0, a period sig nal is generated each 2 x (period+1) receive clock. ckg receive clock gating 0x0 none, continuous clock 0x1 receive clock enabled only if rf low 0x2 receive clock enabled only if rf high 0x3 reserved start receive start 0x0 continuous, as soon as the receiver is enabled, and immediately after the end of transfer of the previous data. 0x1 transmit start 0x2 detection of a low level on rf signal 0x3 detection of a high level on rf signal 0x4 detection of a falling edge on rf signal 0x5 detection of a rising edge on rf signal 0x6 detection of any level change on rf signal 0x7 detection of any edge on rf signal 0x8 compare 0 0x9-0xf reserved
360 32015a?avr32?02/07 AT32AP7001 24.9.4 ssc receive frame mode register name: rfmr access type: read/write ? datlen: data length 0: forbidden value (1-bit data length not supported). any other value: the bit stream contains datlen + 1 data bits. moreover, it defines the transfer size performed by the pdc2 assigned to the receiver. if datlen is lower or equal to 7, data transfers are in bytes. if datlen is between 8 and 15 (included), half-words are transferred, and for any other value, 32-bit words are transferred. ? loop: loop mode 0: normal operating mode. 1: rd is driven by td, rf is driven by tf and tk drives rk. ? msbf: most significant bit first 0: the lowest significant bit of the data register is sampled first in the bit stream. 1: the most significant bit of the data register is sampled first in the bit stream. ? datnb: data number per frame this field defines the number of data words to be received after each transfer start, which is equal to (datnb + 1). ? fslen: receive frame sync length this field defines the length of the receive frame sync signal and the number of bits sampled and stored in the receive sync data register. when this mode is selected by the start field in the receive clock mode register, it also deter- mines the length of the sampled data to be compared to the compare 0 or compare 1 register. pulse length is equal to (fslen + 1) receive clock periods. th us, if fslen is 0, the receive frame sync signal is gener- ated during one receive clock period. 31 30 29 28 27 26 25 24 ----???fsedge 23 22 21 20 19 18 17 16 ? fsos fslen 15 14 13 12 11 10 9 8 ???? datnb 76543210 msbf ? loop datlen
361 32015a?avr32?02/07 AT32AP7001 ? fsos: receive frame sync output selection ? fsedge: frame sync edge detection determines which edge on frame sy nc will generate the in terrupt rxsyn in the ssc status register. fsos selected receive frame sync signal rf pin 0x0 none input-only 0x1 negative pulse output 0x2 positive pulse output 0x3 driven low during data transfer output 0x4 driven high during data transfer output 0x5 toggling at each start of data transfer output 0x6-0x7 reserved undefined fsedge frame sync edge detection 0x0 positive edge detection 0x1 negative edge detection
362 32015a?avr32?02/07 AT32AP7001 24.9.5 ssc transmit clock mode register name: tcmr access type: read/write ? cks: transmit clock selection ? cko: transmit clock output mode selection ? cki: transmit clock inversion 0: the data outpu ts (data and frame sync signals) are shifted out on tr ansmit clock falling edge . the frame sync signal input is sampled on transmit clock rising edge. 1: the data outputs (data and frame sync signals) are shifted out on transmit clock rising edge. the frame sync signal input is sampled on tran smit clock falling edge. cki affects only the transmit clock and not the output clock signal. 31 30 29 28 27 26 25 24 period 23 22 21 20 19 18 17 16 sttdly 15 14 13 12 11 10 9 8 ???? start 76543210 ckg cki cko cks cks selected transmit clock 0x0 divided clock 0x1 rk clock signal 0x2 tk pin 0x3 reserved cko transmit clock output mode tk pin 0x0 none input-only 0x1 continuous transmit clock output 0x2 transmit clock only during data transfers output 0x3-0x7 reserved
363 32015a?avr32?02/07 AT32AP7001 ? ckg: transmit clock gating selection ? start: transmit start selection ? sttdly: transmit start delay if sttdly is not 0, a delay of sttdly clock cycles is inse rted between the start event and the actual start of transmission of data. when the transmitter is programmed to start sync hronously with the receiver, the delay is also applied. note: sttdly must be set carefully. if sttdly is too short in respect to tag (transmit sync data) emission, data is emit- ted instead of the end of tag. ? period: transmit period divider selection this field selects the divider to apply to the selected transmi t clock to generate a new frame sync signal. if 0, no period signal is generated. if not 0, a period signal is generated at each 2 x (period+1) transmit clock. ckg transmit clock gating 0x0 none, continuous clock 0x1 transmit clock enabled only if tf low 0x2 transmit clock enabled only if tf high 0x3 reserved start transmit start 0x0 continuous, as soon as a word is written in the thr register (if transmit is enabled), and immediately after the end of transfer of the previous data. 0x1 receive start 0x2 detection of a low level on tf signal 0x3 detection of a high level on tf signal 0x4 detection of a falling edge on tf signal 0x5 detection of a rising edge on tf signal 0x6 detection of any level change on tf signal 0x7 detection of any edge on tf signal 0x8 - 0xf reserved
364 32015a?avr32?02/07 AT32AP7001 24.9.6 ssc transmit frame mode register name: tfmr access type: read/write ? datlen: data length 0: forbidden value (1-bit data length not supported). any other value: the bit stream contains datlen + 1 data bits. moreover, it defines the transfer size performed by the pdc2 assigned to the transmit. if datlen is lower or equal to 7, data transfers are bytes, if datlen is between 8 and 15 (included), half-words are transferred, and for any other value, 32-bit words are transferred. ? datdef: data default value this bit defines the level driven on the td pin while out of tran smission. note that if the pin is defined as multi-drive by th e pio controller, the pin is enabled only if the scc td output is 1. ? msbf: most significant bit first 0: the lowest significant bit of the data register is shifted out first in the bit stream. 1: the most significant bit of the data register is shifted out first in the bit stream. ? datnb: data number per frame this field defines the number of data words to be transferred after each transfer start, which is equal to (datnb +1). ? fslen: transmit frame sync length this field defines the length of the transmit frame sync sig nal and the number of bits shifted out from the transmit sync data register if fsden is 1. pulse length is equal to (fslen + 1) transmit clock periods, i.e., the pulse length can range from 1 to 16 transmit clock periods. if fslen is 0, the transmit frame sync signal is generated during one transmit clock period. 31 30 29 28 27 26 25 24 ----???fsedge 23 22 21 20 19 18 17 16 fsden fsos fslen 15 14 13 12 11 10 9 8 ???? datnb 76543210 m s b f ? dat d e f dat l e n
365 32015a?avr32?02/07 AT32AP7001 ? fsos: transmit frame sync output selection ? fsden: frame sync data enable 0: the td line is driven with the default va lue during the transmi t frame sync signal. 1: tshr value is shifted out during the tran smission of the transmi t frame sync signal. ? fsedge: frame sync edge detection determines which edge on frame sync will gene rate the interrupt tx syn (status register). fsos selected transmit frame sync signal tf pin 0x0 none input-only 0x1 negative pulse output 0x2 positive pulse output 0x3 driven low during data transfer output 0x4 driven high during data transfer output 0x5 toggling at each start of data transfer output 0x6-0x7 reserved undefined fsedge frame sync edge detection 0x0 positive edge detection 0x1 negative edge detection
366 32015a?avr32?02/07 AT32AP7001 24.9.7 ssc receive holding register name: rhr access type: read-only ? rdat: receive data right aligned regardless of the number of data bits defined by datlen in rfmr. 31 30 29 28 27 26 25 24 rdat 23 22 21 20 19 18 17 16 rdat 15 14 13 12 11 10 9 8 rdat 76543210 rdat
367 32015a?avr32?02/07 AT32AP7001 24.9.8 ssc transmit holding register name: thr access type: write-only ? tdat: transmit data right aligned regardless of the number of data bits defined by datlen in tfmr. 31 30 29 28 27 26 25 24 tdat 23 22 21 20 19 18 17 16 tdat 15 14 13 12 11 10 9 8 tdat 76543210 tdat
368 32015a?avr32?02/07 AT32AP7001 24.9.9 ssc receive synchronization holding register name: rshr access type: read-only ? rsdat: receive synchronization data 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rsdat 76543210 rsdat
369 32015a?avr32?02/07 AT32AP7001 24.9.10 ssc transmit synchronization holding register name: tshr access type: read/write ? tsdat: transmit synchronization data 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 tsdat 76543210 tsdat
370 32015a?avr32?02/07 AT32AP7001 24.9.11 ssc receive compare 0 register name: rc0r access type: read/write ? cp0: receive compare data 0 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 cp0 76543210 cp0
371 32015a?avr32?02/07 AT32AP7001 24.9.12 ssc receive compare 1 register name: rc1r access type: read/write ? cp1: receive compare data 1 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 cp1 76543210 cp1
372 32015a?avr32?02/07 AT32AP7001 24.9.13 ssc status register name: sr access type: read-only ? txrdy: transmit ready 0: data has been loaded in thr and is waiting to be loaded in the transmit shift register (tsr). 1: thr is empty. ? txempty: transmit empty 0: data remains in thr or is currently transmitted from tsr. 1: last data written in thr has been loaded in tsr and last data loaded in tsr has been transmitted. ? endtx: end of transmission 0: the register tcr has not reached 0 since the last write in tcr or tncr. 1: the register tcr has reached 0 since the last write in tcr or tncr. ? txbufe: transmit buffer empty 0: tcr or tncr have a value other than 0. 1: both tcr and tncr have a value of 0. ? rxrdy: receive ready 0: rhr is empty. 1: data has been received and loaded in rhr. ? ovrun: receive overrun 0: no data has been loaded in rhr while previous data has not been read since the last read of the status register. 1: data has been loaded in rhr while previous data has not yet been read since the last read of the status register. ? endrx: end of reception 0: data is written on the receive counter register or receive ne xt counter register. 1: end of pdc transfer when receive counter register has arrived at zero. ? rxbuff: receive buffer full 0: rcr or rncr have a value other than 0. 1: both rcr and rncr have a value of 0. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ??????rxentxen 15 14 13 12 11 10 9 8 ????rxsynt xsyn cp1 cp0 76543210 rxbuff endrx ovrun rxrdy txbufe endtx txempty txrdy
373 32015a?avr32?02/07 AT32AP7001 ?cp0: compare 0 0: a compare 0 has not occurred since the last read of the status register. 1: a compare 0 has occurred since the last read of the status register. ?cp1: compare 1 0: a compare 1 has not occurred since the last read of the status register. 1: a compare 1 has occurred since the last read of the status register. ? txsyn: transmit sync 0: a tx sync has not occurred since the last read of the status register. 1: a tx sync has occurred since the last read of the status register. ? rxsyn: receive sync 0: an rx sync has not occurred since the last read of the status register. 1: an rx sync has occurred since the last read of the status register. ? txen: transmit enable 0: transmit is disabled. 1: transmit is enabled. ? rxen: receive enable 0: receive is disabled. 1: receive is enabled.
374 32015a?avr32?02/07 AT32AP7001 24.9.14 ssc interrupt enable register name: ier access type: write-only ? txrdy: transmit ready interrupt enable 0: no effect. 1: enables the transmit ready interrupt. ? txempty: transmit empty interrupt enable 0: no effect. 1: enables the transmit empty interrupt. ? endtx: end of transmission interrupt enable 0: no effect. 1: enables the end of transmission interrupt. ? txbufe: transmit buffer empty interrupt enable 0: no effect. 1: enables the transmit buffer empty interrupt ? rxrdy: receive ready interrupt enable 0: no effect. 1: enables the receive ready interrupt. ? ovrun: receive overrun interrupt enable 0: no effect. 1: enables the receive overrun interrupt. ? endrx: end of reception interrupt enable 0: no effect. 1: enables the end of reception interrupt. ? rxbuff: receive buffer full interrupt enable 0: no effect. 1: enables the receive buffer full interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????rxsynt xsyn cp1 cp0 76543210 rxbuff endrx ovrun rxrdy txbufe endtx txempty txrdy
375 32015a?avr32?02/07 AT32AP7001 ? cp0: compare 0 interrupt enable 0: no effect. 1: enables the compare 0 interrupt. ? cp1: compare 1 interrupt enable 0: no effect. 1: enables the compare 1 interrupt. ? txsyn: tx sync interrupt enable 0: no effect. 1: enables the tx sync interrupt. ? rxsyn: rx sync interrupt enable 0: no effect. 1: enables the rx sync interrupt.
376 32015a?avr32?02/07 AT32AP7001 24.9.15 ssc interrupt disable register name: idr access type: write-only ? txrdy: transmit ready interrupt disable 0: no effect. 1: disables the transmit ready interrupt. ? txempty: transmit empty interrupt disable 0: no effect. 1: disables the transmit empty interrupt. ? endtx: end of transmission interrupt disable 0: no effect. 1: disables the end of transmission interrupt. ? txbufe: transmit buffer empty interrupt disable 0: no effect. 1: disables the transmit buffer empty interrupt. ? rxrdy: receive ready interrupt disable 0: no effect. 1: disables the rece ive ready interrupt. ? ovrun: receive overrun interrupt disable 0: no effect. 1: disables the receive overrun interrupt. ? endrx: end of reception interrupt disable 0: no effect. 1: disables the end of reception interrupt. ? rxbuff: receive buffer full interrupt disable 0: no effect. 1: disables the receiv e buffer full interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????rxsynt xsyn cp1 cp0 76543210 rxbuff endrx ovrun rxrdy txbufe endtx txempty txrdy
377 32015a?avr32?02/07 AT32AP7001 ? cp0: compare 0 interrupt disable 0: no effect. 1: disables the compare 0 interrupt. ? cp1: compare 1 interrupt disable 0: no effect. 1: disables the compare 1 interrupt. ? txsyn: tx sync interrupt enable 0: no effect. 1: disables the tx sync interrupt. ? rxsyn: rx sync interrupt enable 0: no effect. 1: disables the rx sync interrupt.
378 32015a?avr32?02/07 AT32AP7001 24.9.16 ssc interrupt mask register name: imr access type: read-only ? txrdy: transmit ready interrupt mask 0: the transmit ready interrupt is disabled. 1: the transmit ready interrupt is enabled. ? txempty: transmit empty interrupt mask 0: the transmit empty interrupt is disabled. 1: the transmit empty interrupt is enabled. ? endtx: end of transmission interrupt mask 0: the end of transmission interrupt is disabled. 1: the end of transmission interrupt is enabled. ? txbufe: transmit buffer empty interrupt mask 0: the transmit buffer empty interrupt is disabled. 1: the transmit buffer empty interrupt is enabled. ? rxrdy: receive ready interrupt mask 0: the receive ready interrupt is disabled. 1: the receive ready interrupt is enabled. ? ovrun: receive overrun interrupt mask 0: the receive overrun interrupt is disabled. 1: the receive overrun interrupt is enabled. ? endrx: end of reception interrupt mask 0: the end of reception interrupt is disabled. 1: the end of reception interrupt is enabled. ? rxbuff: receive buffer full interrupt mask 0: the receive buffer full interrupt is disabled. 1: the receive buffer full interrupt is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????rxsynt xsyn cp1 cp0 76543210 rxbuf endrx ovrun rxrdy txbufe endtx txempty txrdy
379 32015a?avr32?02/07 AT32AP7001 ? cp0: compare 0 interrupt mask 0: the compare 0 interrupt is disabled. 1: the compare 0 interrupt is enabled. ? cp1: compare 1 interrupt mask 0: the compare 1 interrupt is disabled. 1: the compare 1 interrupt is enabled. ? txsyn: tx sync interrupt mask 0: the tx sync interrupt is disabled. 1: the tx sync interrupt is enabled. ? rxsyn: rx sync interrupt mask 0: the rx sync interrupt is disabled. 1: the rx sync interrupt is enabled.
380 32015a?avr32?02/07 AT32AP7001 25. universal synchronous/asynchro nous receiver/transmitter (usart) rev: 6089i 25.1 features ? programmable baud rate generator ? 5- to 9-bit full-duplex synchronous or asynchronous serial communications ? 1, 1.5 or 2 stop bits in asynchronous mode or 1 or 2 stop bits in synchronous mode ? parity generation and error detection ? framing error detection, overrun error detection ? msb- or lsb-first ? optional break generation and detection ? by 8 or by 16 over-sampling receiver frequency ? optional hardware handshaking rts-cts ? receiver time-out and transmitter timeguard ? optional multidrop mode with address generation and detection ? rs485 with driver control signal ? iso7816, t = 0 or t = 1 protocols for interfacing with smart cards ? nack handling, error counter with repetition and iteration limit ? irda modulation and demodulation ? communication at up to 115.2 kbps ? test modes ? remote loopback, local loopback, automatic echo ? supports connection of two peripheral dma controller channels (pdc) ? offers buffer transfer without processor intervention 25.2 description the universal synchronous asynchronous rece iver transceiver (usart) provides one full duplex universal synchronous asynchronous serial link. data frame format is widely programma- ble (data length, parity, number of stop bits) to support a maximum of standards. the receiver implements parity error, framing error and overrun error detection. the receiver time-out enables handling variable-length frames and the transmitt er timeguard facilitates communications with slow remote devices. multidrop communications are also supported through address bit han- dling in reception and transmission. the usart features three test modes: remote loopback, local loopback and automatic echo. the usart supports specific operating modes providing interfaces on rs485 buses, with iso7816 t = 0 or t = 1 smart card slots and infrared transceivers. the hardware handshaking feature enables an out-of-band flow control by automatic management of the pins rts and cts. the usart supports the connection to the peripheral dma controller, which enables data transfers to the transmitter and from the receiver. the pdc provides chained buffer manage- ment without any intervention of the processor.
381 32015a?avr32?02/07 AT32AP7001 25.3 block diagram figure 25-1. usart block diagram peripheral dma controller channel channel interrupt controller receiver usart interrupt rxd txd sck usart pio controller cts rts transmitter baud rate generator user interface power manager mck slck div mck/div peripheral bus
382 32015a?avr32?02/07 AT32AP7001 25.4 application block diagram figure 25-2. application block diagram 25.5 i/o lines description table 25-1. i/o line description name description type active level sck serial clock i/o txd transmit serial data i/o rxd receive serial data input cts clear to send input low rts request to send output low smart card slot usart rs485 drivers differential bus irda transceivers field bus driver emv driver irda driver irlap rs232 drivers serial port serial driver ppp
383 32015a?avr32?02/07 AT32AP7001 25.6 product dependencies 25.6.1 i/o lines the pins used for interfacing the usart may be multiplexed with the pio lines. the program- mer must first program the pio controller to assign the desired usart pins to their peripheral function. if i/o lines of the usart are not used by the application, they can be used for other purposes by the pio controller. to prevent the txd line from falling when the usart is di sabled, the use of an internal pull up is mandatory. 25.6.2 power management the usart is not continuously clocked. the programmer must ensure that the usart clock is enabled in the power manager (pm) before using the usart. however, if the application does not require usart operations, the usart clock can be stopped when not needed and be restarted late r. in this case, the usart will resume its operations where it left off. master clock (mck) in the usart description is the clock for the peripheral bus to which the usart is connected. 25.6.3 interrupt the usart interrupt line is connected on one of the internal sources of the interrupt controller. using the usart interrupt requires the interrupt controller to be programmed first.
384 32015a?avr32?02/07 AT32AP7001 25.7 functional description the usart is capable of managing several ty pes of serial synchronous or asynchronous communications. it supports the following communication modes: ? 5- to 9-bit full-duplex asynchronous serial communication ? msb- or lsb-first ? 1, 1.5 or 2 stop bits ? parity even, odd, marked, space or none ? by 8 or by 16 over-sampling receiver frequency ? optional hardware handshaking ? optional break management ? optional multidrop serial communication ? high-speed 5- to 9-bit full-duplex synchronous serial communication ? msb- or lsb-first ? 1 or 2 stop bits ? parity even, odd, marked, space or none ? by 8 or by 16 over-sampling frequency ? optional hardware handshaking ? optional break management ? optional multidrop serial communication ? rs485 with driver control signal ? iso7816, t0 or t1 protocols for interfacing with smart cards ? nack handling, error counter with repetition and iteration limit ? infrared irda modulation and demodulation ? test modes ? remote loopback, local loopback, automatic echo 25.7.1 baud rate generator the baud rate generator provides the bit period clock named the baud rate clock to both the receiver and the transmitter. the baud rate generator clock source can be selected by setting the usclks field in the mode register (mr) between: ? the master clock mck ? a division of the master clock, the divider being product dependent, but generally set to 8 ? the external clock, available on the sck pin the baud rate generator is based upon a 16-bit divider, which is programmed with the cd field of the baud rate generator register (brgr). if cd is programmed at 0, the baud rate gener- ator does not generate any clock. if cd is programmed at 1, the divider is bypassed and becomes inactive.
385 32015a?avr32?02/07 AT32AP7001 if the external sck clock is selected, the duration of the low and high levels of the signal pro- vided on the sck pin must be longer than a master clock (mck) period. the frequency of the signal provided on sck must be at least 4.5 times lower than mck. figure 25-3. baud rate generator 25.7.1.1 baud rate in asynchronous mode if the usart is programmed to operate in as ynchronous mode, the selected clock is first divided by cd, which is field programmed in the baud rate generator register (brgr). the resulting clock is provided to the receiver as a sampling clock and then divided by 16 or 8, depending on the programming of the over bit in mr. if over is set to 1, the receiver sampling is 8 times higher than the baud rate clock. if over is cleared, the sampling is performed at 16 times the baud rate clock. the following formula performs the calculation of the baud rate. this gives a maximum baud rate of mck divided by 8, assuming that mck is the highest possi- ble clock and that over is programmed at 1. 25.7.1.2 baud rate calculation example table 25-2 shows calculations of cd to obtain a baud rate at 38400 bauds for different source clock frequencies. this table also shows the actual resulting baud rate and the error. mck/div 16-bit counter 0 baud rate clock cd cd sampling divider 0 1 >1 sampling clock reserved mck sck usclks over sck sync sync usclks = 3 1 0 2 3 0 1 0 1 fidi baudrate selectedclock 82 over ? () cd () -------------------------------------------- = table 25-2. baud rate example (over = 0) source clock expected baud rate calculation result cd actual baud rate error mhz bit/s bit/s 3 686 400 38 400 6.00 6 38 400.00 0.00% 4 915 200 38 400 8.00 8 38 400.00 0.00% 5 000 000 38 400 8.14 8 39 062.50 1.70%
386 32015a?avr32?02/07 AT32AP7001 the baud rate is calculated with the following formula: the baud rate error is calculated with the following formula. it is not recommended to work with an error higher than 5%. 25.7.1.3 fractional baud rate in asynchronous mode the baud rate generator previously defined is su bject to the following limitation: the output fre- quency changes by only integer multiples of the reference frequency. an approach to this problem is to integrate a fractional n clock generator that has a high resolution. the generator architecture is modified to obtain baud rate c hanges by a fraction of the reference source clock. this fractional part is programmed with the fp field in the baud rate generator register (brgr). if fp is not 0, the fractional part is acti vated. the resolution is one eighth of the clock divider. this feature is only available when using usart normal mode. the fractional baud rate is calculated using the following formula: 7 372 800 38 400 12.00 12 38 400.00 0.00% 8 000 000 38 400 13.02 13 38 461.54 0.16% 12 000 000 38 400 19.53 20 37 500.00 2.40% 12 288 000 38 400 20.00 20 38 400.00 0.00% 14 318 180 38 400 23.30 23 38 908.10 1.31% 14 745 600 38 400 24.00 24 38 400.00 0.00% 18 432 000 38 400 30.00 30 38 400.00 0.00% 24 000 000 38 400 39.06 39 38 461.54 0.16% 24 576 000 38 400 40.00 40 38 400.00 0.00% 25 000 000 38 400 40.69 40 38 109.76 0.76% 32 000 000 38 400 52.08 52 38 461.54 0.16% 32 768 000 38 400 53.33 53 38 641.51 0.63% 33 000 000 38 400 53.71 54 38 194.44 0.54% 40 000 000 38 400 65.10 65 38 461.54 0.16% 50 000 000 38 400 81.38 81 38 580.25 0.47% 60 000 000 38 400 97.66 98 38 265.31 0.35% 70 000 000 38 400 113.93 114 38 377.19 0.06% table 25-2. baud rate example (over = 0) (continued) source clock expected baud rate calculation result cd actual baud rate error baudrate mck cd 16 ? = error 1 expectedbaudrate actualbaudrate -------------------------------------------------- - ?? ?? ? = baudrate selectedclock 82 over ? () cd fp 8 ------- + ?? ?? ?? ?? ---------------------------------------------------------------- - =
387 32015a?avr32?02/07 AT32AP7001 the modified architecture is presented below: figure 25-4. fractional baud rate generator 25.7.1.4 baud rate in synchronous mode if the usart is programmed to operate in synchronous mode, the selected clock is simply divided by the field cd in brgr. in synchronous mode, if the external clock is selected (usclks = 3), the clock is provided directly by the signal on the usart sck pin. no division is active. the value written in brgr has no effect. the external clock frequency must be at least 4.5 times lower than the system clock. when either the external clock sck or the inte rnal clock divided (mck/div) is selected, the value programmed in cd must be even if the user has to ensure a 50:50 mark/space ratio on the sck pin. if the internal clock mck is selected, the baud rate generator ensures a 50:50 duty cycle on the sck pin, even if the value programmed in cd is odd. 25.7.1.5 baud rate in iso 7816 mode the iso7816 specification defines the bit rate with the following formula: where: ? b is the bit rate ? di is the bit-rate adjustment factor ? fi is the clock frequency division factor ? f is the iso7816 clock frequency (hz) mck/div 16-bit counter 0 baud rate clock cd cd sampling divider 0 1 >1 sampling clock reserved mck sck usclks over sck sync sync usclks = 3 1 0 2 3 0 1 0 1 fidi glitch-free logic modulus control fp fp baudrate selectedclock cd ------------------------------------- - = b di fi ----- - f =
388 32015a?avr32?02/07 AT32AP7001 di is a binary value encoded on a 4-bit field, named di, as represented in table 25-3 . fi is a binary value encoded on a 4-bi t field, named fi, as represented in table 25-4 . table 25-5 shows the resulting fi/di ratio, which is the ratio between the iso7816 clock and the baud rate clock. if the usart is configured in iso7816 mode, th e clock selected by the usclks field in the mode register (mr) is first divided by the valu e programmed in the field cd in the baud rate generator register (brgr). the resulting clock can be provided to the sck pin to feed the smart card clock inputs. this means that the clko bit can be set in mr. this clock is then divided by the value progra mmed in the fi_di_ratio field in the fi_di_ratio register (fidi). this is performed by the sampling divider, which performs a division by up to 2047 in iso7816 mode. the non-integer values of the fi/di ratio are not supported and the user must program the fi_di_ratio field to a value as close as possible to the expected value. the fi_di_ratio field resets to the value 0x174 (372 in decimal) and is the most common divider between the iso7816 clock and the bit rate (fi = 372, di = 1). figure 25-5 shows the relation between the elementary time unit, corresponding to a bit time, and the iso 7816 clock. table 25-3. binary and decimal values for di di field 0001 0010 0011 0100 0101 0110 1000 1001 di (decimal)1 2 4 8 163212 20 table 25-4. binary and decimal values for fi fi field 0000 0001 0010 0011 0100 0101 0110 1001 1010 1011 1100 1101 fi (decimal 372 372 558 744 1116 1488 1860 512 768 1024 1536 2048 table 25-5. possible values for the fi/di ratio fi/di 372 558 774 1116 1488 1806 512 768 1024 1536 2048 1 372 558 744 1116 1488 1860 512 768 1024 1536 2048 2 186 279 372 558 744 930 256 384 512 768 1024 4 93 139.5 186 279 372 465 128 192 256 384 512 8 46.5 69.75 93 139.5 186 232.5 64 96 128 192 256 16 23.25 34.87 46.5 69.75 93 116.2 32 48 64 96 128 32 11.62 17.43 23.25 34.87 46.5 58.13 16 24 32 48 64 12 31 46.5 62 93 124 155 42.66 64 85.33 128 170.6 20 18.6 27.9 37.2 55.8 74.4 93 25.6 38.4 51.2 76.8 102.4
389 32015a?avr32?02/07 AT32AP7001 figure 25-5. elementary time unit (etu) 25.7.2 receiver and transmitter control after reset, the receiver is disabled. the user must enable the receiver by setting the rxen bit in the control register (cr). however, the receiver registers can be programmed before the receiver clock is enabled. after reset, the transmitter is disabled. the user must enable it by setting the txen bit in the control register (cr). however, the transmitter registers can be programmed before being enabled. the receiver and the transmitter can be enabled together or independently. at any time, the software can perform a reset on the receiver or the transmitter of the usart by setting the corresponding bit, rstrx and rsttx re spectively, in the control register (cr). the reset commands have the same effect as a hardware reset on the corresponding logic. regardless of what the receiver or the transmi tter is performing, the communication is immedi- ately stopped. the user can also independently disable the receiv er or the transmitter by setting rxdis and txdis respectively in cr. if the receiver is disabled during a character reception, the usart waits until the end of reception of the current character, then the reception is stopped. if the transmitter is disabled while it is operating, the usart waits the end of transmission of both the current character and character being stored in the transmit holding register (thr). if a time- guard is programmed, it is handled normally. 25.7.3 synchronous and asynchronous modes 25.7.3.1 transmitter operations the transmitter performs the same in both synchronous and asynchronous operating modes (sync = 0 or sync = 1). one start bit, up to 9 da ta bits, one optional parity bit and up to two stop bits are successively shifted out on the txd pin at each falling edge of the programmed serial clock. the number of data bits is selected by the chrl field and the mode 9 bit in the mode register (mr). nine bits are selected by setting the mode 9 bit regardless of the chrl field. the parity bit is set according to the par field in mr. the even, odd, space, marked or none parity bit can be configured. the msbf field in mr configures wh ich data bit is sent first. if written at 1, the most significant bit is sent first. at 0, the less signi ficant bit is sent first. the number of stop bits is selected by the nbstop field in mr. the 1.5 stop bit is supported in asynchronous mode only. 1 etu iso7816 clock on sck iso7816 i/o line on txd fi_di_ratio iso7816 clock cycles
390 32015a?avr32?02/07 AT32AP7001 figure 25-6. character transmit the characters are sent by writing in the tr ansmit holding register (thr). the transmitter reports two status bits in the channel status register (csr): txrdy (transmitter ready), which indicates that thr is empt y and txempty, which indicates that all the characters written in thr have been processed. when the current character processing is completed, the last character written in thr is transferred into the shift register of the transmitter and thr becomes empty, thus txrdy raises. both txrdy and txempty bits are low since the transmitter is disabled. writing a character in thr while txrdy is active has no effect and the written character is lost. figure 25-7. transmitter status 25.7.3.2 manchester encoder when the manchester encoder is in use, c haracters transmitted through the usart are encoded based on biphase manchester ii format. to enable this mode, set the man field in the mr register to 1. depending on polarity configurat ion, a logic level (zero or one), is transmitted as a coded signal one-to-zero or zero-to-one. thus, a transition always occurs at the midpoint of each bit time. it consumes more bandwidth than the original nrz signal (2x) but the receiver has more error control since the expected input must show a change at the center of a bit cell. an example of manchester encoded sequence is: th e byte 0xb1 or 10110001 encodes to 10 01 10 10 01 01 01 10, assuming the default polarity of the encoder. figure 25-8 illustrates this coding scheme. d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit example: 8-bit, parity enabled one stop baud rate clock d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock start bit write us_thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy txempty
391 32015a?avr32?02/07 AT32AP7001 figure 25-8. nrz to manchester encoding the manchester encoded character can also be enc apsulated by adding both a configurable preamble and a start frame delimiter pattern. depending on the configuration, the preamble is a training sequence, composed of a pre-defined pattern with a programmable length from 1 to 15 bit times. if the preamble length is set to 0, the preamble waveform is not generated prior to any character. the preamble pattern is chosen among the following sequences: all_one, all_zero, one_zero or zero_one, writing the field tx_pp in the man register, the field tx_pl is used to configure the preamble length. figure 25-9 illustrates and defines the valid patterns. to improve flexibility, the encodi ng scheme can be configured using the tx_mpol field in the man register. if the tx_mpol field is set to zero (default), a logic zero is encoded with a zero-to-one transition and a logic one is encoded with a one-to-zero transition. if the tx_mpol field is set to one, a logic one is encoded with a one-to-zero transition and a logic zero is encoded with a zero-to-one transition. figure 25-9. preamble patterns, default polarity assumed a start frame delimiter is to be configured using the onebit field in the mr register. it consists of a user-defined pattern that indicates the beginning of a valid data. figure 25-10 illustrates these patterns. if the start frame delimiter, also known as start bit, is one bit, (onebit at 1), a logic zero is manchester encoded and indicates that a new character is being sent serially on the line. if the start frame delimiter is a synchronization pattern also referred to as sync (onebit at 0), a sequence of 3 bit times is sent serially on the line to indicate the start of a new character. nrz encoded data manchester encoded data 10110001 txd manchester encoded data txd sfd data 8 bit width "all_one" preamble manchester encoded data txd sfd data 8 bit width "all_zero" preamble manchester encoded data txd sfd data 8 bit width "zero_one" preamble manchester encoded data txd sfd data 8 bit width "one_zero" preamble
392 32015a?avr32?02/07 AT32AP7001 the sync waveform is in itself an invalid manchester waveform as the transition occurs at the middle of the second bit time. two distinct sync patterns are used: the command sync and the data sync. the command sync has a logic one level for one and a half bit times, then a transition to logic zero for the second one and a half bit times. if the modsync field in the mr register is set to 1, the next character is a command. if it is set to 0, the next character is a data. when direct memory access is used, the modsync field can be immediately updated with a modified character located in memory. to enable this mode, var_sync field in mr register must be set to 1. in this case, the modsync field in mr is bypassed and the sync configuration is held in the txsynh in the thr register. the usart character format is modified and includes sync information. figure 25-10. start frame delimiter 25.7.3.3 drift compensation drift compensation is available only in 16x oversampling mode. an ha rdware recovery system allows a larger clock drift. to enable the hardwa re system, the bit in th e man register must be set. if the rxd edge is one 16x clock cycle from the expected edge, this is considered as nor- mal jitter and no corrective actions is taken. if the rxd event is between 4 and 2 clock cycles before the expected edge, then the current period is shortened by one clock cycle. if the rxd event is between 2 and 3 clock cycles after the expected edge, then the current period is length- ened by one clock cycle. these intervals are considered to be drift and so corrective actions are automatically taken. manchester encoded data txd sfd data one bit start frame delimiter preamble length is set to 0 manchester encoded data txd sfd data command sync start frame delimiter manchester encoded data txd sfd data data sync start frame delimiter
393 32015a?avr32?02/07 AT32AP7001 figure 25-11. bit resynchronization 25.7.3.4 asynchronous receiver if the usart is programmed in asynchronous operating mode (sync = 0), the receiver over- samples the rxd input line. the oversampling is either 16 or 8 times the baud rate clock, depending on the over bit in the mode register (mr). the receiver samples the rxd line. if the line is sampled during one half of a bit time at 0, a start bit is detected and data, parity and stop bits are successively sampled on the bit rate clock. if the oversampling is 16, (over at 0), a start is detected at the eighth sample at 0. then, data bits, parity bit and stop bit are sampled on each 16 sampling clock cycle. if the oversampling is 8 (over at 1), a start bit is detected at the fourth sample at 0. then, data bits, parity bit and stop bit are sampled on each 8 sampling clock cycle. the number of data bits, first bit sent and parity mode are selected by the same fields and bits as the transmitter, i.e. respectively chrl, mo de9, msbf and par. the number of stop bits has no effect on the receiver as it considers only one stop bit, regardless of the field nbstop, so that resynchronization between the receiv er and the transmitter can occur. moreover, as soon as the stop bit is sampled, the receiver starts looking for a new start bit so that resynchroni- zation can also be accomplished when the transmitter is operating with one stop bit. figure 25-12 and figure 25-13 illustrate start detection and character reception when usart operates in asynchronous mode. rxd oversampling 16x clock sampling point expected edge tolerance synchro. jump sync jump synchro. error synchro. error
394 32015a?avr32?02/07 AT32AP7001 figure 25-12. asynchronous start detection figure 25-13. asynchronous character reception 25.7.3.5 manchester decoder when the man field in mr register is set to 1, the manchester decoder is enabled. the decoder performs both preamble and start frame delimiter detection. one input line is dedicated to manchester encoded input data. an optional preamble sequence can be defined, it s length is user-defined and totally indepen- dent of the emitter side. use rx_pl in man regi ster to configure the length of the preamble sequence. if the length is set to 0, no preamble is detected and the function is disabled. in addi- tion, the polarity of the input stream is programmable with rx_mpol field in man register. depending on the desired application the preamble pattern matching is to be defined via the rx_pp field in man. see figure 25-9 for available preamble patterns. unlike preamble, the start frame delimiter is shared between manchester encoder and decoder. so, if onebit field is set to 1, only a zero encoded manchester can be detected as a valid start frame delimiter. if onebit is set to 0, only a sync pattern is detected as a valid start frame delimiter. decoder operates by detecting transition on incoming stream. if rxd is sampled dur- ing one quarter of a bit time at zero, a start bit is detected. see figure 25-14 . the sample pulse rejection mechanism applies. sampling clock (x16) rxd start detection sampling baud rate clock rxd start rejection sampling 12345678 12345670 1234 12345678 9 10111213141516 d0 sampling d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit stop bit example: 8-bit, parity enabled baud rate clock start detection 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples 16 samples
395 32015a?avr32?02/07 AT32AP7001 figure 25-14. asynchronous star t bit detection the receiver is activated and starts preamble and frame delimiter detection, sampling the data at one quarter and then three quarters. if a valid preamble pattern or start frame delimiter is detected, the receiver continues decoding with the same synchronization. if the stream does not match a valid pattern or a valid start frame delimiter, the receiver re-synchronizes on the next valid edge.the minimum time threshold to estimate the bit value is three quarters of a bit time. if a valid preamble (if used) followed with a valid start frame delimiter is detected, the incoming stream is decoded into nrz data and passed to usart for processing. figure 25-15 illustrates manchester pattern mismatch. when incoming data stream is passed to the usart, the receiver is also able to detect manchester code vi olation. a code violation is a lack of transition in the middle of a bit cell. in this case, mane flag in csr register is raised. it is cleared by writing the control register (cr) with the rststa bit at 1. see figure 25-16 for an example of manchester error detection during data phase. figure 25-15. preamble pattern mismatch figure 25-16. manchester error flag when the start frame delimiter is a sync pattern (onebit field at 0), both command and data delimiter are supported. if a valid sync is detec ted, the received character is written as rxchr manchester encoded data txd 1234 sampling clock (16 x) start detection manchester encoded data txd sfd data preamble length is set to 8 preamble mismatch invalid pattern preamble mismatch manchester coding error manchester encoded data txd sfd preamble length is set to 4 elementary character bit time manchester coding error detected sampling points preamble subpacket and start frame delimiter were successfully decoded entering usart character area
396 32015a?avr32?02/07 AT32AP7001 field in the rhr register and the rxsynh is updated. rxchr is set to 1 when the received character is a command, and it is set to 0 if the received character is a data. this mechanism alleviates and simplifies the direct memory access as the character contains its own sync field in the same register. as the decoder is setup to be used in unipolar mode, the first bit of the frame has to be a zero-to- one transition. 25.7.3.6 radio interface: manchester encoded usart application this section describes low data rate rf transmission systems and their integration with a manchester encoded usart. these systems are based on transmitter and receiver ics that support ask and fsk modulation schemes. the goal is to perform full duplex radio transmissi on of characters using two different frequency carriers. see the configuration in figure 25-17 . figure 25-17. manchester encoded characters rf transmission the usart module is configured as a manchester encoder/decoder. looking at the down- stream communication channel, manchester encoded characters are serially sent to the rf emitter. this may also include a user defined preamble and a start frame delimiter. mostly, pre- amble is used in the rf receiver to distinguish between a valid data from a transmitter and signals due to noise. the manchester stream is then modulated. see figure 25-18 for an exam- ple of ask modulation scheme. when a logic one is sent to the ask modulator, the power amplifier, referred to as pa, is enabled and transmits an rf signal at downstream frequency. when a logic zero is transmitted, the rf signal is turned off. if the fsk modulator is activated, two different frequencies are used to transmit dat a. when a logic 1 is sent, the modulator out- puts an rf signal at frequency f0 and switches to f1 if the data sent is a 0. see figure 25-19 . from the receiver side, another carrier frequency is used. the rf receiver performs a bit check operation examining demodulated data stream. if a valid pattern is detected, the receiver switches to receiving mode. the demodulated stream is sent to the manchester decoder. because of bit checking inside rf ic, the data transferred to the microcontroller is reduced by a lna vco rf filter demod control bi-dir line pa rf filter mod vco control manchester decoder manchester encoder usart receiver usart emitter ask/fsk upstream receiver ask/fsk downstream transmitter upstream emitter downstream receiver serial configuration interface fup frequency carrier fdown frequency carrier
397 32015a?avr32?02/07 AT32AP7001 user-defined number of bits. the manchester preamble length is to be defined in accordance with the rf ic configuration. figure 25-18. ask modulator output figure 25-19. fsk modulator output 25.7.3.7 synchronous receiver in synchronous mode (sync = 1), the receiver samples the rxd signal on each rising edge of the baud rate clock. if a lo w level is detected, it is considered as a start. all data bits, the parity bit and the stop bits are sampled and the receiver waits for the next start bit. synchronous mode operations provide a high speed transfer capability. configuration fields and bits are the same as in asynchronous mode. figure 25-20 illustrates a character rec eption in synchronous mode. figure 25-20. synchronous mode character reception manchester encoded data default polarity unipolar output txd ask modulator output uptstream frequency f0 nrz stream 10 0 1 manchester encoded data default polarity unipolar output txd fsk modulator output uptstream frequencies [f0, f0+offset] nrz stream 10 0 1 d0 d1 d2 d3 d4 d5 d6 d7 rxd start sampling parity bit stop bit example: 8-bit, parity enabled 1 stop baud rate clock
398 32015a?avr32?02/07 AT32AP7001 25.7.3.8 receiver operations when a character reception is completed, it is transferred to the receive holding register (rhr) and the rxrdy bit in the st atus register (csr) rises. if a character is completed while the rxrdy is set, the ovre (overrun error) bit is set. the last character is transferred into rhr and overwrites the previous one. the ovre bit is cleared by writing the control register (cr) with the rststa (reset status) bit at 1. figure 25-21. receiver status d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write us_cr rxrdy ovre d0 d1 d2 d3 d4 d5 d6 d7 start bit parity bit stop bit rststa = 1 read us_rhr
399 32015a?avr32?02/07 AT32AP7001 25.7.3.9 parity the usart supports five parity modes selected by programming the par field in the mode register (mr). the par field also enables the multidrop mode, see ?multidrop mode? on page 400 . even and odd parity bit generation and error detection are supported. if even parity is selected, the parity generator of the transmitter drives the parity bit at 0 if a num- ber of 1s in the character data bit is even, and at 1 if the number of 1s is odd. accordingly, the receiver parity checker counts the number of received 1s and reports a parity error if the sam- pled parity bit does not correspond. if odd parity is selected, the parity generator of the transmitter drives the parity bit at 1 if a number of 1s in the character data bit is even, and at 0 if the number of 1s is odd. accordingly, the receiver parity checker counts the number of received 1s and reports a parity error if the sampled parity bit does not correspond. if the mark parity is used, the parity generator of the transmitter drives the parity bit at 1 for all characters. the receiver parity checker reports an error if the parity bit is sampled at 0. if the space parity is used, the parity generator of the transmitter drives the parity bit at 0 for all characters. the receiver parity checker reports an error if the parity bit is sampled at 1. if parity is disabled, the transmitter does not generate any parity bit and the receiver does not report any parity error. table 25-6 shows an example of the parity bit for the character 0x41 (character ascii ?a?) depending on the configuration of the usart. because there are two bits at 1, 1 bit is added when a parity is odd, or 0 is added when a parity is even. when the receiver detects a parity error, it sets the pare (parity error) bit in the channel status register (csr). the pare bit can be cleared by writing the control register (cr) with the rst- sta bit at 1. figure 25-22 illustrates the parity bit status setting and clearing. table 25-6. parity bit examples character hexa binary parity bit parity mode a 0x41 0100 0001 1 odd a 0x41 0100 0001 0 even a 0x41 0100 0001 1 mark a 0x41 0100 0001 0 space a 0x41 0100 0001 none none
400 32015a?avr32?02/07 AT32AP7001 figure 25-22. parity error 25.7.3.10 multidrop mode if the par field in the mode register (mr) is programmed to the value 0x6 or 0x07, the usart runs in multidrop mode. this mode differentia tes the data characters and the address charac- ters. data is transmitted with the parity bit at 0 and addresses are transmitted with the parity bit at 1. if the usart is configured in multidrop mode, the receiver sets the pare parity error bit when the parity bit is high and the transmitter is able to send a character with the parity bit high when the control register is written with the senda bit at 1. to handle parity error, the pare bit is cleared when the control register is written with the bit rststa at 1. the transmitter sends an address byte (parity bit set) when senda is written to cr. in this case, the next byte written to thr is transmitted as an address. any character written in thr without having written the command senda is transmitted normally with the parity at 0. 25.7.3.11 transmitter timeguard the timeguard feature enables the usar t interface with slow remote devices. the timeguard function enables the transmitter to insert an idle state on the txd line between two characters. this idle state actually acts as a long stop bit. the duration of the idle state is programmed in the tg field of the transmitter timeguard regis- ter (ttgr). when this field is programmed at zero no timeguard is generated. otherwise, the transmitter holds a high level on txd after each transmitted byte during the number of bit peri- ods programmed in tg in addition to the number of stop bits. as illustrated in figure 25-23 , the behavior of txrdy and txempty status bits is modified by the programming of a timeguard. txrdy rises only when the start bit of the next character is sent, and thus remains at 0 during the timeguard transmission if a character has been written in thr. txempty remains low until the timeguard transmission is completed as the timeguard is part of the current character being transmitted. d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit bad parity bit stop bit baud rate clock write us_cr pare rxrdy rststa = 1
401 32015a?avr32?02/07 AT32AP7001 figure 25-23. timeguard operations table 25-7 indicates the maximum length of a timeguard period that the transmitter can handle in relation to the function of the baud rate. 25.7.3.12 receiver time-out the receiver time-out provides support in handling variable-length frames. this feature detects an idle condition on the rxd line. when a time-out is detected, the bit timeout in the channel status register (csr) rises and can generate an interrupt, thus indicating to the driver an end of frame. the time-out delay period (during which the receiver waits for a new character) is programmed in the to field of the receiver time-out register (rtor). if the to field is programmed at 0, the receiver time-out is disabled and no time-out is detected. the timeou t bit in csr remains at 0. otherwise, the receiver loads a 16-bit counter with the value programmed in to. this counter is decremented at each bit period and reloaded ea ch time a new character is received. if the counter reaches 0, the timeout bit in the status register rises. the user can either: d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock start bit tg = 4 write us_thr d0 d1 d2 d3 d4 d5 d6 d7 parity bit stop bit txrdy txempty tg = 4 table 25-7. maximum timeguard length depending on baud rate baud rate bit time timeguard bit/sec s ms 1 200 833 212.50 9 600 104 26.56 14400 69.4 17.71 19200 52.1 13.28 28800 34.7 8.85 33400 29.9 7.63 56000 17.9 4.55 57600 17.4 4.43 115200 8.7 2.21
402 32015a?avr32?02/07 AT32AP7001 ? obtain an interrupt when a time-out is detected after having received at least one character. this is performed by writing the control regist er (cr) with the sttto (start time-out) bit at 1. ? obtain a periodic interrupt while no character is received. this is performed by writing cr with the retto (reload and start time-out) bit at 1. if sttto is performed, the counter clock is stopped until a first character is received. the idle state on rxd before the start of the frame does not provide a time-out. this prevents having to obtain a periodic interrupt and enables a wait of the end of frame when the idle state on rxd is detected. if retto is performed, the counter starts counting down immediately from the value to. this enables generation of a periodic interrupt so t hat a user time-out can be handled, for example when no key is pressed on a keyboard. figure 25-24 shows the block diagram of the receiver time-out feature. figure 25-24. receiver time-out block diagram table 25-8 gives the maximum time-out period for some standard baud rates. 16-bit time-out counter 0 to timeout baud rate clock = character received retto load clock 16-bit value sttto dq 1 clear table 25-8. maximum time-out period baud rate bit time time-out bit/sec s ms 600 1 667 109 225 1 200 833 54 613 2 400 417 27 306 4 800 208 13 653 9 600 104 6 827 14400 69 4 551 19200 52 3 413 28800 35 2 276 33400 30 1 962 56000 18 1 170 57600 17 1 138 200000 5 328
403 32015a?avr32?02/07 AT32AP7001 25.7.3.13 framing error the receiver is capable of detecting framing errors. a framing error happens when the stop bit of a received character is detected at level 0. this can occur if the receiver and the transmitter are fully desynchronized. a framing error is reported on the frame bit of the channel status register (csr). the frame bit is asserted in the middle of the stop bit as soon as the framing error is detected. it is cleared by writing the control register (cr) with the rststa bit at 1. figure 25-25. framing error status 25.7.3.14 transmit break the user can request the transmitter to generate a break condition on the txd line. a break con- dition drives the txd line low during at least one complete character. it appears the same as a 0x00 character sent with the parity and the stop bits at 0. however, the transmitter holds the txd line at least during one character until the user requests the break condition to be removed. a break is transmitted by writing the control register (cr) with the sttbrk bit at 1. this can be performed at any time, either while the transmitter is empty (no character in either the shift reg- ister or in thr) or when a character is being transmitted. if a break is requested while a character is being shifted out, t he character is first completed be fore the txd line is held low. once sttbrk command is requested further sttbrk commands are ignored until the end of the break is completed. the break condition is removed by writing cr with the stpbrk bit at 1. if the stpbrk is requested before the end of the minimum break duration (one character, including start, data, parity and stop bits), the transmitter ensures that the break condition completes. the transmitter considers the break as though it is a character, i.e. the sttbrk and stpbrk commands are taken into account only if the txrdy bit in csr is at 1 and the start of the break condition clears the txrdy and txempty bits as if a character is processed. writing cr with the both sttbrk and stpbrk bits at 1 can lead to an unpredictable result. all stpbrk commands requested without a previous sttbrk command are ignored. a byte writ- ten into the transmit holding re gister while a break is pending, but not started, is ignored. d0 d1 d2 d3 d4 d5 d6 d7 rxd start bit parity bit stop bit baud rate clock write us_cr frame rxrdy rststa = 1
404 32015a?avr32?02/07 AT32AP7001 after the break condition, the transmitter returns the txd line to 1 for a minimum of 12 bit times. thus, the transmitter ensures that the remote receiver detects correctly the end of break and the start of the next character. if the timeguard is programmed with a value higher than 12, the txd line is held high for the timeguard period. after holding the txd line for this period, the transmitter resumes normal operations. figure 25-26 illustrates the effect of both the start break (sttbrk ) and stop break (stpbrk) commands on the txd line. figure 25-26. break transmission 25.7.3.15 receive break the receiver detects a break condition when all data, parity and stop bits are low. this corre- sponds to detecting a framing error with data at 0x00, but frame remains low. when the low stop bit is detected, the receiver asserts the rxbrk bit in csr. this bit may be cleared by writing the control register (cr) with the bit rststa at 1. an end of receive break is detected by a high leve l for at least 2/16 of a bit period in asynchro- nous operating mode or one sample at high level in synchronous operating mode. the end of break detection also asserts the rxbrk bit. 25.7.3.16 hardware handshaking the usart features a hardware handshaking out-of-band flow control. the rts and cts pins are used to connect with the remote device, as shown in figure 25-27 . figure 25-27. connection with a remote device for hardware handshaking d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock write us_cr txrdy txempty stpbrk = 1 sttbrk = 1 break transmission end of break usart txd cts remote device rxd txd rxd rts rts cts
405 32015a?avr32?02/07 AT32AP7001 setting the usart to operate with hardware handshaking is performed by writing the mode field in the mode register (mr) to the value 0x2. the usart behavior when hardware handshaking is enabled is the same as the behavior in standard synchronous or asynchronous mode, except that the receiver drives the rts pin as described below and the level on the cts pin modifies the behavior of the transmitter as described below. using this mode requires usin g the pdc channel for reception. the transmitter can handle hardware handshaking in any case. figure 25-28 shows how the receiver operates if hardware handshaking is enabled. the rts pin is driven high if the receiver is disabled and if the status rxbuff (receive buffer full) com- ing from the pdc channel is high. normally, the remote device does not start transmitting while its cts pin (driven by rts) is high. as soon as the receiver is enabled , the rts falls, indicating to the remote device that it can start transmitt ing. defining a new buffer to the pdc clears the status bit rxbuff and, as a result, asserts the pin rts low. figure 25-28. receiver behavior when operating with hardware handshaking figure 25-29 shows how the transmitter operates if hardware handshaking is enabled. the cts pin disables the transmitt er. if a character is being processi ng, the transmitter is disabled only after the completion of the current character and transmission of the next character happens as soon as the pin cts falls. figure 25-29. transmitter behavior when operating with hardware handshaking 25.7.4 iso7816 mode the usart features an iso7816-compatible operating mode. this mode permits interfacing with smart cards and security access modules (sam) communicating through an iso7816 link. both t = 0 and t = 1 protocols defined by the iso7816 specification are supported. setting the usart in iso7816 mode is performed by writing the mode field in the mode regis- ter (mr) to the value 0x4 for protocol t = 0 and to the value 0x5 for protocol t = 1. 25.7.4.1 iso7816 mode overview the iso7816 is a half duplex communication on only one bidirectional line. the baud rate is determined by a division of the clo ck provided to the remote device (see ?baud rate generator? on page 384 ). rts rxbuff write us_cr rxen = 1 rxd rxdis = 1 cts txd
406 32015a?avr32?02/07 AT32AP7001 the usart connects to a smart card as shown in figure 25-30 . the txd line becomes bidirec- tional and the baud rate generator feeds the iso7816 clock on the sck pin. as the txd pin becomes bidirectional, its output remains driven by the output of the transmitter but only when the transmitter is active while its input is direct ed to the input of the receiver. the usart is con- sidered as the master of the communication as it generates the clock. figure 25-30. connection of a smart card to the usart when operating in iso7816, either in t = 0 or t = 1 modes, the character format is fixed. the configuration is 8 data bits, ev en parity and 1 or 2 stop bits, regardless of the values pro- grammed in the chrl, mode9, par and chmode fields. msbf can be used to transmit lsb or msb first. parity bit (par) can be used to transmit in normal or inverse mode. refer to ?usart mode register? on page 417 and ?par: parity type? on page 418 . the usart cannot operate concurrently in both receiver and transmitter modes as the commu- nication is unidirectional at a time. it has to be configured according to the required mode by enabling or disabling either the receiver or the transmitter as desired. enabling both the receiver and the transmitter at the same time in iso7816 mode may lead to unpredictable results. the iso7816 specification defines an inverse transmission format. data bits of the character must be transmitted on the i/o line at their negative value. the usart does not support this for- mat and the user has to perform an exclusive or on the data before writing it in the transmit holding register (thr) or after reading it in the receive holding register (rhr). 25.7.4.2 protocol t = 0 in t = 0 protocol, a character is made up of one start bit, eight data bits, one parity bit and one guard time, which lasts two bit times. the transmitter shifts out the bits and does not drive the i/o line during the guard time. if no parity error is detected, the i/o line remains at 1 during the guard time and the transmitter can continue with the transmission of the next character, as shown in figure 25-31 . if a parity error is detected by the receiver, it drives the i/o line at 0 during the guard time, as shown in figure 25-32 . this error bit is also named nack, for non acknowledge. in this case, the character lasts 1 bit time more, as the guard time length is the same and is added to the error bit time which lasts 1 bit time. when the usart is the receiver and it detects an error, it does not load the erroneous character in the receive holding register (rhr). it appropriately sets the pare bit in the status register (sr) so that the software can handle the error. smart card sck clk txd i/o usart
407 32015a?avr32?02/07 AT32AP7001 figure 25-31. t = 0 protocol without parity error figure 25-32. t = 0 protocol with parity error 25.7.4.3 receive error counter the usart receiver also records the total number of errors. this can be read in the number of error (ner) register. the nb_errors field ca n record up to 255 errors. reading ner auto- matically clears the nb_errors field. 25.7.4.4 receive nack inhibit the usart can also be configured to inhibit an error. this can be achieved by setting the inack bit in the mode register (mr). if inack is at 1, no error signal is driven on the i/o line even if a parity bit is detected, but the inack bit is set in the status register (sr). the inack bit can be cleared by writing the control re gister (cr) with the rstnack bit at 1. moreover, if inack is set, the erroneous receiv ed character is stored in the receive holding register, as if no error occurred. however, the rxrdy bit does not raise. 25.7.4.5 transmit character repetition when the usart is transmitting a character and gets a nack, it can automatically repeat the character before moving on to the next one. repetition is enabled by writing the max_iteration field in the mode register (mr) at a value higher than 0. each character can be transmitted up to eight times; the firs t transmission plus seven repetitions. if max_iteration does not equal zero, the u sart repeats the character as many times as the value loaded in max_iteration. when the usart repetition number reaches max_iteration, the iteration bit is set in the channel status register (csr). if the repetition of the character is acknowledged by the receiver, the repetitions are stopped and the iteration counter is cleared. the iteration bit in csr can be cleared by writing the control register with the rsit bit at 1. 25.7.4.6 disable successive receive nack the receiver can limit the number of successive nacks sent back to the remote transmitter. this is programmed by setting the bit dsnack in the mode register (mr). the maximum num- ber of nack transmitted is programmed in the max_iteration field. as soon as d0 d1 d2 d3 d4 d5 d6 d7 rxd parity bit baud rate clock start bit guard time 1 next start bit guard time 2 d0 d1 d2 d3 d4 d5 d6 d7 i/o parity bit baud rate clock start bit guard time 1 start bit guard time 2 d0 d1 error repetition
408 32015a?avr32?02/07 AT32AP7001 max_iteration is reached, the character is cons idered as correct, an acknowledge is sent on the line and the iteration bit in the channel status register is set. 25.7.4.7 protocol t = 1 when operating in iso7816 protocol t = 1, the transmission is similar to an asynchronous for- mat with only one stop bit. the parity is generated when transmitting and checked when receiving. parity error detection sets the par e bit in the channel status register (csr). 25.7.5 irda mode the usart features an irda mode supplying half-duplex point-to-point wireless communica- tion. it embeds the modulator and demodulator which allows a glueless connection to the infrared transceivers, as shown in figure 25-33 . the modulator and demodulator are compliant with the irda specification version 1.1 and support data transfer speeds ranging from 2.4 kb/s to 115.2 kb/s. the usart irda mode is enabled by setting the mo de field in the mode register (mr) to the value 0x8. the irda filter register (if) allows configuring the demodulator filter. the usart transmitter and receiver operate in a normal asynchronous mode and all parameters are acces- sible. note that the modulator and the demodulator are activated. figure 25-33. connection to irda transceivers the receiver and the transmitter must be enabled or disabled according to the direction of the transmission to be managed. 25.7.5.1 irda modulation for baud rates up to and including 115.2 kbits/sec, the rzi modulation scheme is used. ?0? is represented by a light pulse of 3/16th of a bit time. some examples of signal pulse duration are shown in table 25-9 . irda transceivers rxd rx txd tx usart demodulator modulator receiver transmitter table 25-9. irda pulse duration baud rate pulse duration (3/16) 2.4 kb/s 78.13 s 9.6 kb/s 19.53 s 19.2 kb/s 9.77 s
409 32015a?avr32?02/07 AT32AP7001 figure 25-34 shows an example of character transmission. figure 25-34. irda modulation 25.7.5.2 irda baud rate table 25-10 gives some examples of cd values, baud rate error and pulse duration. note that the requirement on the maximum acceptable error of 1.87% must be met. 38.4 kb/s 4.88 s 57.6 kb/s 3.26 s 115.2 kb/s 1.63 s table 25-9. irda pulse duration baud rate pulse duration (3/16) bit period bit period 3 16 start bit data bits stop bit 0 0 0 0 0 1 1 1 1 1 transmitter output txd table 25-10. irda baud rate error peripheral clock baud rate cd baud rate error pulse time 3 686 400 115 200 2 0.00% 1.63 20 000 000 115 200 11 1.38% 1.63 32 768 000 115 200 18 1.25% 1.63 40 000 000 115 200 22 1.38% 1.63 3 686 400 57 600 4 0.00% 3.26 20 000 000 57 600 22 1.38% 3.26 32 768 000 57 600 36 1.25% 3.26 40 000 000 57 600 43 0.93% 3.26 3 686 400 38 400 6 0.00% 4.88 20 000 000 38 400 33 1.38% 4.88 32 768 000 38 400 53 0.63% 4.88 40 000 000 38 400 65 0.16% 4.88 3 686 400 19 200 12 0.00% 9.77 20 000 000 19 200 65 0.16% 9.77 32 768 000 19 200 107 0.31% 9.77 40 000 000 19 200 130 0.16% 9.77
410 32015a?avr32?02/07 AT32AP7001 25.7.5.3 irda demodulator the demodulator is based on the irda receive filter co mprised of an 8-bit down counter which is loaded with the value pr ogrammed in if. when a falling edge is detected on the rxd pin, the fil- ter counter starts counting down at the master clock (mck) speed. if a rising edge is detected on the rxd pin, the counter stops and is reloaded with if. if no rising edge is detected when the counter reaches 0, the input of the receiver is driven low during one bit time. figure 25-35 illustrates the operations of the irda demodulator. figure 25-35. irda demodulator operations as the irda mode uses the same logic as the iso7816, note that the fi_di_ratio field in fidi must be set to a value higher than 0 in order to assure irda communications operate correctly. 3 686 400 9 600 24 0.00% 19.53 20 000 000 9 600 130 0.16% 19.53 32 768 000 9 600 213 0.16% 19.53 40 000 000 9 600 260 0.16% 19.53 3 686 400 2 400 96 0.00% 78.13 20 000 000 2 400 521 0.03% 78.13 32 768 000 2 400 853 0.04% 78.13 table 25-10. irda baud rate error (continued) peripheral clock baud rate cd baud rate error pulse time mck rxd receiver input pulse rejected 65432 6 1 driven low during 16 baud rate clock cycles 65432 0 pulse accepted counter value
411 32015a?avr32?02/07 AT32AP7001 25.7.6 rs485 mode the usart features the rs485 mode to enable li ne driver control. while operating in rs485 mode, the usart behaves as though in asynch ronous or synchronous mode and configuration of all the parameters is possible. the differenc e is that the rts pin is driven high when the transmitter is operating. the behavior of the rts pin is controlled by the txempty bit. a typical connection of the usart to a rs485 bus is shown in figure 25-36 . figure 25-36. typical connection to a rs485 bus the usart is set in rs485 mode by programming the mode field in the mode register (mr) to the value 0x1. the rts pin is at a level inverse to the txempt y bit. significantly, the rts pin remains high when a timeguard is programmed so that the line can remain driven after the last character com- pletion. figure 25-37 gives an example of the rts waveform during a character transmission when the timeguard is enabled. figure 25-37. example of rts drive with timeguard usart rts txd rxd differential bus d0 d1 d2 d3 d4 d5 d6 d7 txd start bit parity bit stop bit baud rate clock tg = 4 write us_thr txrdy txempty rts
412 32015a?avr32?02/07 AT32AP7001 25.7.7 test modes the usart can be programmed to operate in three different test modes. the internal loopback capability allows on-boar d diagnostics. in the loopback mode the usart interface pins are dis- connected or not and reconfigured for loopback internally or externally. 25.7.7.1 normal mode normal mode connects the rxd pin on the receiver input and the transmitter output on the txd pin. figure 25-38. normal mode configuration 25.7.7.2 automatic echo mode automatic echo mode allows bit-by-bit retransmission. when a bit is received on the rxd pin, it is sent to the txd pin, as shown in figure 25-39 . programming the transmitter has no effect on the txd pin. the rxd pin is still connected to the receiver input, thus the receiver remains active. figure 25-39. automatic echo mode configuration 25.7.7.3 local loopback mode local loopback mode c onnects the output of the transmitter directly to the input of the receiver, as shown in figure 25-40 . the txd and rxd pins are not used. the rxd pin has no effect on the receiver and the txd pin is continuously driven high, as in idle state. figure 25-40. local loopback mode configuration receiver transmitter rxd txd receiver transmitter rxd txd receiver transmitter rxd txd 1
413 32015a?avr32?02/07 AT32AP7001 25.7.7.4 remote loopback mode remote loopback mode directly connects the rxd pin to the txd pin, as shown in figure 25-41 . the transmitter and the receiver are disabled an d have no effect. this mode allows bit-by-bit retransmission. figure 25-41. remote loopback mode configuration receiver transmitter rxd txd 1
414 32015a?avr32?02/07 AT32AP7001 25.8 usart user interface table 25-11. usart memory map offset register name access reset state 0x0000 control register cr write-only ? 0x0004 mode register mr read/write ? 0x0008 interrupt enable register ier write-only ? 0x000c interrupt disable register idr write-only ? 0x0010 interrupt mask register imr read-only 0x0 0x0014 channel status register csr read-only ? 0x0018 receiver holding register rhr read-only 0x0 0x001c transmitter holding register thr write-only ? 0x0020 baud rate generator register brgr read/write 0x0 0x0024 receiver time-out register rtor read/write 0x0 0x0028 transmitter timeguard register ttgr read/write 0x0 0x2c - 0x3c reserved ? ? ? 0x0040 fi di ratio register fidi read/write 0x174 0x0044 number of errors register ner read-only ? 0x0048 reserved - ? ? 0x004c irda filter register if read/write 0x0 0x0050 manchester encoder decoder register man read/write 0x30011004 0x100 - 0x128 reserved for pdc registers ? ? ?
415 32015a?avr32?02/07 AT32AP7001 25.8.1 usart control register name: cr access type: write-only ? rstrx: reset receiver 0: no effect. 1: resets the receiver. ? rsttx: reset transmitter 0: no effect. 1: resets the transmitter. ? rxen: receiver enable 0: no effect. 1: enables the receiver, if rxdis is 0. ? rxdis: receiver disable 0: no effect. 1: disables the receiver. ? txen: transmitter enable 0: no effect. 1: enables the transmitter if txdis is 0. ? txdis: transmitter disable 0: no effect. 1: disables the transmitter. ? rststa: reset status bits 0: no effect. 1: resets the status bits pare, frame, ovre, manerr and rxbrk in csr. ? sttbrk: start break 0: no effect. 1: starts transmission of a break after t he characters present in thr and the transmit shift register have been transmit- ted. no effect if a break is already being transmitted. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????rtsdisrtsen?? 15 14 13 12 11 10 9 8 retto rstnack rstit senda sttto stpbrk sttbrk rststa 76543210 txdis txen rxdis rxen rsttx rstrx ? ?
416 32015a?avr32?02/07 AT32AP7001 ? stpbrk: stop break 0: no effect. 1: stops transmission of the break after a minimum of one char acter length and transmits a high level during 12-bit periods. no effect if no break is being transmitted. ? sttto: start time-out 0: no effect 1: starts waiting for a character before clocking the time-out counter. ? senda: send address 0: no effect. 1: in multidrop mode only, the next character written to the thr is sent with the address bit set. ? rstit: reset iterations 0: no effect. 1: resets iteration in csr. no e ffect if the iso7816 is not enabled. ? rstnack: reset non acknowledge 0: no effect 1: resets nack in csr. ? retto: rearm time-out 0: no effect 1: restart time-out ? rtsen: request to send enable 0: no effect. 1: drives the pin rts to 0. ? rtsdis: request to send disable 0: no effect. 1: drives the pin rts to 1.
417 32015a?avr32?02/07 AT32AP7001 25.8.2 usart mode register name: mr access type: read/write ?mode ? usclks: clock selection ? chrl: character length. 31 30 29 28 27 26 25 24 onebit modsync? man filter ? max_iteration 23 22 21 20 19 18 17 16 ? var_sync dsnack inack over clko mode9 msbf 15 14 13 12 11 10 9 8 chmode nbstop par sync 76543210 chrl usclks mode mode mode of the usart 0000normal 0001rs485 0 0 1 0 hardware handshaking 0011reserved 0 1 0 0 is07816 protocol: t = 0 0101reserved 0 1 1 0 is07816 protocol: t = 1 0111reserved 1000irda 11xxreserved usclks selected clock 00mck 01mck / div 10reserved 11sck chrl character length 0 0 5 bits
418 32015a?avr32?02/07 AT32AP7001 ? sync: synchronous mode select 0: usart operates in asynchronous mode. 1: usart operates in synchronous mode. ? par: parity type ? nbstop: number of stop bits ? chmode: channel mode ? msbf: bit order 0: least significant bit is sent/received first. 1: most significant bit is sent/received first. ? mode9: 9-bit character length 0: chrl defines character length. 1: 9-bit character length. ? cklo: clock output select 0: the usart does not drive the sck pin. 0 1 6 bits 1 0 7 bits 1 1 8 bits par parity type 0 0 0 even parity 001odd parity 0 1 0 parity forced to 0 (space) 0 1 1 parity forced to 1 (mark) 1 0 x no parity 1 1 x multidrop mode nbstop asynchronous (sync = 0) synchronous (sync = 1) 0 0 1 stop bit 1 stop bit 0 1 1.5 stop bits reserved 1 0 2 stop bits 2 stop bits 1 1 reserved reserved chmode mode description 0 0 normal mode 0 1 automatic echo. receiver input is connected to the txd pin. 1 0 local loopback. transmitter output is connected to the receiver input.. 1 1 remote loopback. rxd pin is internally connected to the txd pin.
419 32015a?avr32?02/07 AT32AP7001 1: the usart drives the sck pin if usclks does not select the external clock sck. ? over: oversampling mode 0: 16x oversampling. 1: 8x oversampling. ? inack: inhibit non acknowledge 0: the nack is generated. 1: the nack is not generated. ? dsnack: disable successive nack 0: nack is sent on the iso line as soon as a parity erro r occurs in the received character (unless inack is set). 1: successive parity errors are counted up to the value spec ified in the max_iteration field. these parity errors gener- ate a nack on the iso line. as soon as this value is r eached, no additional nack is sent on the iso line. the flag iteration is asserted. ? var_sync: variable synchronization of command/data sync start frame delimiter 0: user defined configuration of command or data sync field depending on sync value. 1: the sync field is updated when a ch aracter is written into thr register. ? max_iteration defines the maximum number of iterations in mode iso7816, protocol t= 0. ? filter: infrared receive line filter 0: the usart does not filter the receive line. 1: the usart filters the receive line using a three-sample filter (1/16-bit clock) (2 over 3 majority). ? man: manchester encoder/decoder enable 0: manchester encoder/decoder are disabled. 1: manchester encoder/decoder are enabled. ? modsync : manchester synchronization mode 0:the manchester start bit is a 0 to 1 transition 1: the manchester start bit is a 1 to 0 transition. ? onebit: start frame delimiter selector 0: start frame delimiter is command or data sync. 1: start frame delimiter is one bit.
420 32015a?avr32?02/07 AT32AP7001 25.8.3 usart interrupt enable register name: ier access type: write-only ? rxrdy: rxrdy interrupt enable ? txrdy: txrdy interrupt enable ? rxbrk: receiver break interrupt enable ? endrx: end of receive transfer interrupt enable ? endtx: end of transmit interrupt enable ? ovre: overrun error interrupt enable ? frame: framing error interrupt enable ? pare: parity error interrupt enable ? timeout: time-out interrupt enable ? txempty: txempty interrupt enable ? iteration: iteration interrupt enable ? txbufe: buffer empty interrupt enable ? rxbuff: buffer full interrupt enable ? nack: non acknowledge interrupt enable ? ctsic: clear to send input change interrupt enable ? mane: manchester error interrupt enable 0: no effect. 1: enables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? ? ? mane ctsic ? ? ? 15 14 13 12 11 10 9 8 ? ? nack rxbuff txbufe iteration txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
421 32015a?avr32?02/07 AT32AP7001 25.8.4 usart interrupt disable register name: idr access type: write-only ? rxrdy: rxrdy interrupt disable ? txrdy: txrdy interrupt disable ? rxbrk: receiver bre ak interrupt disable ? endrx: end of receive transfer interrupt disable ? endtx: end of transmit interrupt disable ? ovre: overrun error interrupt disable ? frame: framing error interrupt disable ? pare: parity error interrupt disable ? timeout: time-out interrupt disable ? txempty: txempty interrupt disable ? iteration: iteration interrupt disable ? txbufe: buffer empty interrupt disable ? rxbuff: buffer full interrupt disable ? nack: non acknowledge interrupt disable ? ctsic: clear to send input change interrupt disable ? mane: manchester error interrupt disable 0: no effect. 1: disables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? ? ? mane ctsic ? ? ? 15 14 13 12 11 10 9 8 ? ? nack rxbuff txbufe iteration txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
422 32015a?avr32?02/07 AT32AP7001 25.8.5 usart interrupt mask register name: imr access type: read-only ? rxrdy: rxrdy interrupt mask ? txrdy: txrdy interrupt mask ? rxbrk: receiver break interrupt mask ? endrx: end of receive transfer interrupt mask ? endtx: end of transmit interrupt mask ? ovre: overrun error interrupt mask ? frame: framing error interrupt mask ? pare: parity error interrupt mask ? timeout: time-out interrupt mask ? txempty: txempty interrupt mask ? iteration: iteration interrupt mask ? txbufe: buffer empty interrupt mask ? rxbuff: buffer full interrupt mask ? nack: non acknowledge interrupt mask ? ctsic: clear to send input change interrupt mask ? mane: manchester error interrupt mask 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? ? ? mane ctsic ? ? ? 15 14 13 12 11 10 9 8 ? ? nack rxbuff txbufe iteration txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
423 32015a?avr32?02/07 AT32AP7001 25.8.6 usart channel status register name: csr access type: read-only ? rxrdy: receiver ready 0: no complete character has been received since the last read of rhr or the receiver is disabled. if characters were being received when the receiver was disabled, rxrdy changes to 1 when the receiver is enabled. 1: at least one complete ch aracter has been re ceived and rhr has not yet been read. ? txrdy: transmitter ready 0: a character is in the thr waiting to be transferred to the transmit shift register, or an sttbrk command has been requested, or the transmitter is disabled. as soon as the transmitter is enabled, txrdy becomes 1. 1: there is no character in the thr. ? rxbrk: break received/end of break 0: no break received or end of break detected since the last rststa. 1: break received or end of break detected since the last rststa. ? endrx: end of receiver transfer 0: the end of transfer signal from the receive pdc channel is inactive. 1: the end of transfer signal from the receive pdc channel is active. ? endtx: end of transmitter transfer 0: the end of transfer signal from the transmit pdc channel is inactive. 1: the end of transfer signal from the transmit pdc channel is active. ? ovre: overrun error 0: no overrun error has occurred since the last rststa. 1: at least one overrun error has occurred since the last rststa. ? frame: framing error 0: no stop bit has been detected low since the last rststa. 1: at least one stop bit has been detected low since the last rststa. ? pare: parity error 0: no parity error has been detected since the last rststa. 31 30 29 28 27 26 25 24 ???????manerr 23 22 21 20 19 18 17 16 cts ? ? ? ctsic ? ? ? 15 14 13 12 11 10 9 8 ? ? nack rxbuff txbufe iteration txempty timeout 76543210 pare frame ovre endtx endrx rxbrk txrdy rxrdy
424 32015a?avr32?02/07 AT32AP7001 1: at least one parity error has been detected since the last rststa. ? timeout: receiver time-out 0: there has not been a time-out since the last start time-out command or the time-out register is 0. 1: there has been a time-out since the last start time-out command. ? txempty: transmitter empty 0: there are characters in either thr or the trans mit shift register, or the transmitter is disabled. 1: there is at least one character in either thr or the transmit shift register. ? iteration: max number of repetitions reached 0: maximum number of repetitions has not been reached since the last rsit. 1: maximum number of repetitions has been reached since the last rsit. ? txbufe: transmission buffer empty 0: the signal buffer empty from the transmit pdc channel is inactive. 1: the signal buffer empty from the transmit pdc channel is active. ? rxbuff: reception buffer full 0: the signal buffer full from the receive pdc channel is inactive. 1: the signal buffer full from th e receive pdc channel is active. ? nack: non acknowledge 0: no non acknowledge has not been detected since the last rstnack. 1: at least one non acknowledge has been detected since the last rstnack. ? ctsic: clear to send input change flag 0: no input change has been detected on the cts pin since the last read of csr. 1: at least one input change has been detected on the cts pin since the last read of csr. ? cts: image of cts input 0: cts is at 0. 1: cts is at 1. ? manerr: manchester error 0: no manchester error has been detected since the last rststa. 1: at least one manchester error has been detected since the last rststa.
425 32015a?avr32?02/07 AT32AP7001 25.8.7 usart receive holding register name: rhr access type: read-only ? rxchr: received character last character received if rxrdy is set. ? rxsynh: received sync 0: last character received is a data. 1: last character received is a command. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rxsynh ??????rxchr 76543210 rxchr
426 32015a?avr32?02/07 AT32AP7001 25.8.8 usart transmit holding register name: thr access type: write-only ? txchr: character to be transmitted next character to be transmitted after the current character if txrdy is not set. ? txsynh: sync field to be transmitted 0: the next character sent is encoded as a data. start frame delimiter is data sync. 1: the next character sent is encoded as a command. start frame delimiter is command sync. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 txsynh ??????txchr 76543210 txchr
427 32015a?avr32?02/07 AT32AP7001 25.8.9 usart baud rate generator register name: brgr access type: read/write ? cd: clock divider ? fp: fractional part 0: fractional divider is disabled. 1 - 7: baudrate resolution, defined by fp x 1/8. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? fp 15 14 13 12 11 10 9 8 cd 76543210 cd cd mode iso7816 mode = iso7816 sync = 0 sync = 1 over = 0 over = 1 0 baud rate clock disabled 1 to 65535 baud rate = selected clock/16/cd baud rate = selected clock/8/cd baud rate = selected clock /cd baud rate = selected clock/cd/fi_di_ratio
428 32015a?avr32?02/07 AT32AP7001 25.8.10 usart receiver time-out register name: rtor access type: read/write ? to: time-out value 0: the receiver time-out is disabled. 1 - 65535: the receiver time-out is enabled and the time-out delay is to x bit period. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 to 76543210 to
429 32015a?avr32?02/07 AT32AP7001 25.8.11 usart transmitter timeguard register name: ttgr access type: read/write ? tg: timeguard value 0: the transmitter timeguard is disabled. 1 - 255: the transmitter timeguard is enabled and the timeguard delay is tg x bit period. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 tg
430 32015a?avr32?02/07 AT32AP7001 25.8.12 usart fi di ratio register name: fidi access type: read/write reset value : 0x174 ? fi_di_ratio: fi over di ratio value 0: if iso7816 mode is selected, the baud rate generator generates no signal. 1 - 2047: if iso7816 mode is selected, the baud rate is the clock provided on sck divided by fi_di_ratio. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????? fi_di_ratio 76543210 fi_di_ratio
431 32015a?avr32?02/07 AT32AP7001 25.8.13 usart number of errors register name: ner access type: read-only ? nb_errors: number of errors total number of errors that occurred during an iso7816 transfer. this register automatically clears when read. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 nb_errors
432 32015a?avr32?02/07 AT32AP7001 25.8.14 usart manchester configuration register name: man access type: read/write ? tx_pl: transmitter preamble length 0: the transmitter preamble pattern generation is disabled 1 - 15: the preamble length is tx_pl x bit period ? tx_pp: transmitter preamble pattern ? tx_mpol: transmitter manchester polarity 0: logic zero is coded as a zero-to-one transition , logic one is coded as a one-to-zero transition. 1: logic zero is coded as a one-to-zero transition , logic one is coded as a zero-to-one transition. ? rx_pl: receiver preamble length 0: the receiver preamble pattern detection is disabled 1 - 15: the detected preamble length is rx_pl x bit period ? rx_pp: receiver preamble pattern detected ? rx_mpol: receiver manchester polarity 0: logic zero is coded as a zero-to-one transition , logic one is coded as a one-to-zero transition. 31 30 29 28 27 26 25 24 ? drift ? rx_mpol ? ? rx_pp 23 22 21 20 19 18 17 16 ???? rx_pl 15 14 13 12 11 10 9 8 ? ? ? tx_mpol ? ? tx_pp 76543210 ???? tx_pl tx_pp preamble pattern default polari ty assumed (tx_mpol field not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero rx_pp preamble pattern de fault polarity assumed (rx_mpol fi eld not set) 0 0 all_one 0 1 all_zero 10zero_one 11one_zero
433 32015a?avr32?02/07 AT32AP7001 1: logic zero is coded as a one-to-zero transition , logic one is coded as a zero-to-one transition. ? drift: drift compensation 0: the usart can not recover from an important clock drift 1: the usart can recover from clock drift. the 16x clock mode must be enabled.
434 32015a?avr32?02/07 AT32AP7001 25.8.15 usart irda filter register name: if access type: read/write ? irda_filter: irda filter sets the filter of the irda demodulator. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 irda_filter
435 32015a?avr32?02/07 AT32AP7001 26. ac97 controller (ac97c) rev: 6144b 26.1 features ? compliant with ac97 2.2 component specification ? 2 independent comm unication channels ? codec channel, dedicated to the ac97 analog front end control and status monitoring ? 2 channels associated with dma controller interface for isochronous audio streaming transfer ? variable sampling rate ac 97 codec interface support ? one primary codec support ? independent input and output slot to channel assignment, several slots can be assigned to the same channel. ? channels support mono/stereo/multichann el samples of 10, 16, 18 and 20 bits. 26.2 description the ac97 controller is the hardware implementation of the ac97 digital controller (dc?97) com- pliant with ac97 component specification 2.2. the ac97 controller communicates with an audio codec (ac97) or a modem codec (mc?97) via the ac-link digital serial interface. all digital audio, modem and handset data streams, as well as control (command/status) informations are transferred in accordance to the ac-link protocol. the ac97 controller features a dma controller interface for audio streaming transfers. it also supports variable sampling rate and four puls e code modulation (pcm) sample resolutions of 10, 16, 18 and 20 bits.
436 32015a?avr32?02/07 AT32AP7001 26.3 block diagram figure 26-1. functional block diagram ac97 channel a ac97c_cathr ac97c_carhr slot #3...12 ac97 codec channel ac97c_cothr ac97c_corhr slot #2 slot #1,2 ac97 channel b ac97c_cbthr ac97c_cbrhr slot #3...12 ac97 tag controller transmit shift register receive shift register receive shift register receive shift register receive shift register transmit shift register transmit shift register transmit shift register slot #0 slot #0,1 ac97 slot controller slot number 16/20 bits slot number sdi sclk sdo sync user interface mck clock domain bit clock domain ac97c interrupt mck peripheral bus m u x d e m u x
437 32015a?avr32?02/07 AT32AP7001 26.4 pin name list the ac97 reset signal provided to the primary codec can be generated by a pio. 26.5 application block diagram figure 26-2. application block diagram table 26-1. i/o lines description pin name pin description type sclk 12.288-mhz bit-rate clock (referred as bitclk in ac-link spec) input sdi receiver data (referred as sdata_in in ac-link spec) input sync 48-khz frame indicator and synchronizer output sdo transmitter data (referred as sdata_out in ac-link spec) output ac 97 controller sdo sdi piox ac'97 primary codec sync sclk ac97_reset ac97_sync ac97_sdata_out ac97_bitclk ac-link ac97_sdata_in
438 32015a?avr32?02/07 AT32AP7001 26.6 product dependencies 26.6.1 i/o lines the pins used for interfacing the compliant external devices may be multiplexed with pio lines. before using the ac97 controller receiver, the pio controller must be configured in order for the ac97c receiver i/o lines to be in ac97 controller peripheral mode. before using the ac97 controller transmitter, the pio controller must be configured in order for the ac97c transmitter i/o lines to be in ac97 controlle r peripheral mode. 26.6.2 power management the ac97 clock is generated by the power manager. before using the ac97, the programmer must ensure that the ac?97 clock is enabled in the power manager. in the ac97 description, master clock (mck) is the clock of the peripheral bus to which the ac97 is connected. it is important that that the mck clock frequency is higher than the sclk (bit clock) clock frequancy as signals that cross the two clock domains are re-synchronized. 26.6.3 interrupt the ac97 interface has an interrupt line connected to the interrupt controller. in order to handle interrupts, the interrupt controller must be programmed before configuring the ac97. all ac97 controller interrupts can be enabled/dis abled by writing to the ac97 controller inter- rupt enable/disable registers. each pending and unmasked ac97 controller interrupt will assert the interrupt line. the ac97 controller interrupt service routine can get the interrupt source in two steps: ? reading and anding ac97 controller interrupt mask register (imr) and ac97 controller status register (sr). ? reading ac97 controller channel x status register (cxsr).)
439 32015a?avr32?02/07 AT32AP7001 26.7 functional description 26.7.1 protocol overview ac-link protocol is a bidirectional, fixed clock rate, serial digital stream. ac-link handles multiple input and output pulse code modulation pcm audio streams, as well as control register accesses employing a time division multiplexed (tdm) scheme that divides each audio frame in 12 outgoing and 12 incoming 20-bit wide data slots. figure 26-3. bidirectional ac-link fr ame with slot assignment slot # ac97fs tag cmd addr cmd data 0 ac97tx (controller output) ac97rx (codec output) pcm l front pcm r front line 1 dac pcm center pcm r surr pcm lfe line 2 dac hset dac io ctrl tag status addr status data pcm left line 1 dac pcm mic rsved rsved rsved line 2 adc hset adc io status 12 3 4 56 7 8 9 1011 12 pcm l surr pcm right table 26-2. ac-link output slots transmitted from the ac97c controller slot # pin description 0tag 1 command address port 2 command data port 3,4 pcm playback left/right channel 5 modem line 1 output channel 6, 7, 8 pcm center/left surround/right surround 9pcm lfe dac 10 modem line 2 output channel 11 modem handset output channel 12 modem gpio control channel table 26-3. ac-link input slots transmitte d from the ac97c controller slot # pin description 0tag 1 status address port 2 status data port 3,4 pcm playback left/right channel 5 modem line 1 adc 6 dedicated microphone adc 7, 8, 9 vendor reserved 10 modem line 2 adc 11 modem handset input adc 12 modem io status
440 32015a?avr32?02/07 AT32AP7001 26.7.2 slot description 26.7.2.1 tag slot the tag slot, or slot 0, is a 16-bit wide slot that always goes at the beginning of an outgoing or incoming frame. within tag slot, the first bit is a global bit that flags the entire frame validity. the next 12 bit positions sampled by the ac97 cont roller indicate which of the corresponding 12 time slots contain valid data. the slot?s last two bits (combined) called codec id, are used to dis- tinguish primary and secondary codec. the 16-bit wide tag slot of the output frame is automatically generated by the ac97 controller according to the transmit request of each channel and to the slotreq from the previous input frame, sent by the ac97 codec, in variable sample rate mode. 26.7.2.2 codec slot 1 the command/status slot is a 20-bit wide slot used to control features, and monitors status for ac97 codec functions. the control interface architecture supports up to sixty-four 16-bit wide read/write registers. only the even registers are currently defined and addressed. slot 1?s bitmap is the following: ? bit 19 is for read/write command, 1= read, 0 = write. ? bits [18:12] are for control register index. ? bits [11:0] are reserved. 26.7.2.3 codec slot 2 slot 2 is a 20-bit wide slot used to carry 16-bit wide ac97 codec control register data. if the cur- rent command port operation is a read, the entire slot time is stuffed with zeros. its bitmap is the following: ? bits [19:4] are the control register data ? bits [3:0] are reserved and stuffed with zeros. 26.7.2.4 data slots [3:12] slots [3:12] are 20-bit wide data slots, they usually carry audio pcm or/and modem i/o data.
441 32015a?avr32?02/07 AT32AP7001 26.7.3 ac97 controller channel organization the ac97 controller features a codec channel and 2 logical channels; channel a and channel b. the codec channel controls ac97 codec register s, it enables write and read configuration val- ues in order to bring the ac97 codec to an operating state. the codec channel always runs slot 1 and slot 2 exclusively, in both input and output directions. channel a and channel b transfer data to/from ac97 codec. all audio samples and modem data must transit by these two channels. each slot of the input or the output frame that belongs to this range [3 to 12] can be operated by either channel a or channel b. the slot to cha nnel assignment is configured by two registers: ? ac97 controller input channel assignment register (ica) ? ac97 controller output channel assignment register (oca) the ac97 controller input channel assignment register (ica) configures the input slot to chan- nel assignment. the ac97 controller output channel assignment register (oca) configures the output slot to channel assignment. a slot can be left unassigned to a channel by the ac97 controller. slots 0, 1,and 2 cannot be assigned to channel a or to channel b through the oca and ica registers. the width of sample data, that transit via channel a and channel b varies and can take one of these values; 10, 16, 18 or 20 bits. figure 26-4. logical channel assignment slot # ac97fs tag cmd data 0 ac97tx (controller output) ac97rx (codec output) pcm l front pcm r front line 1 dac pcm center pcm l surr pcm r surr pcm lfe line 2 dac hset dac io ctrl tag status addr status data pcm left pcm right line 1 dac pcm mic rsved rsved rsved line 2 adc hset adc io status 12 3 4 56 7 8 91011 12 codec channel channel a codec channel channel a ac97c_oca = 0x0000_0209 ac97c_ica = 0x0000_0009 cmd addr
442 32015a?avr32?02/07 AT32AP7001 26.7.3.1 ac97 controller setup the following operations must be performed in order to bring the ac97 controller into an operat- ing state: 1. enable the ac97 controller clock in the power manager. 2. turn on ac97 function by enabling the ena bit in ac97 controller mode register (mr). 3. configure the input channe l assignment by controlling the ac97 controller input assignment register (ica). 4. configure the output channel assignment by controlling the ac97 controller input assignment register (oca). 5. configure sample width for channel a and ch annel b by writing the size bit field in ac97c channel a mode register (camr) and ac97c channel b mode register (cbmr). the application can write 10, 16, 18,or 20-bit wide pcm samples through the ac97 interface and they will be trans ferred into 20-bit wide slots. 6. configure data endianness for channel a and channel b by writing cem bit field in camr and cbmr registers. data on the ac-link are shifted msb first. the application can write little- or big-endian data to the ac97 controller interface. 7. configure the pio controller to drive the reset signal of the external codec. the reset signal must fulfill external ac97 codec timing requirements. 8. enable channel a and/or channel b by writing cen bit field in camr and cbmr registers. 26.7.3.2 transmit operation the application must perform the following steps in order to send data via a channel to the ac97 codec: ? check if previous data has been sent by polling txrdy flag in the ac97c channel x status register (cxsr). x being one of the 2 channels. ? write data to the ac97 controller channel x transmit holdin g register (cxthr). once data has been transferred to the channel x shift register, the txrdy flag is automatically set by the ac97 controller which allows the application to start a new write action. the applica- tion can also wait for an interrupt notice associated with txrdy in order to send data. the interrupt remains active until txrdy flag is cleared..
443 32015a?avr32?02/07 AT32AP7001 figure 26-5. audio transfer (pcm l front, pcm r front) on channel x the txempty flag in the ac97 controller channel x status register (cxsr) is set when all requested transmissions for a channel have been shifted on the ac-link. the application can either poll txempty flag in cxsr or wait for an interrupt notice associated with the same flag. in most cases, the ac97 controller is embedded in chips that target audio player devices. in such cases, the ac97 controller is exposed to heavy audio transfers. using the polling tech- nique increases processor overhead and may fail to keep the required pace under an operating system. in order to avoid these polling drawbacks, the app lication can perform audio streams by using a dma controller (dmac) connected to both ch annels, which reduces processor overhead and increases performance especially under an operating system. the dmac transmit counter values must be equal to the number of pcm samples to be trans- mitted, each sample goes in one slot. 26.7.3.3 ac97 output frame the ac97 controller outputs a thirteen-slot frame on the ac-link. the first slot (tag slot or slot 0) flags the validity of the entire frame and the validity of each slot; whether a slot carries valid data or not. slots 1 and 2 are used if the application performs control and status monitoring actions on ac97 codec control/status registers. slots [3:12] are used according to the content of the ac97 controller output channel assignment regi ster (oca). if the application performs many transmit requests on a channel, some of the slots associated to this channel or all of them will carry valid data. slot # ac97fs tag cmd addr cmd data 0 ac97tx (controller output) pcm l front pcm r front line 1 dac pcm center pcm l surr pcm r surr pcm lfe line 2 dac hset dac io ctrl 12 3 4 56 7 8 9 1011 12 txrdycx (ac97c_sr) write access to ac97c_thrx pcm l front transfered to the shift register pcm r front transfered to the shift register txempty (ac97c_sr)
444 32015a?avr32?02/07 AT32AP7001 26.7.3.4 receive operation the ac97 controller can also receive data from ac97 codec. data is received in the channel?s shift register and then transferred to the ac97 controller channel x read holding register. to read the newly received data, the application must perform the following steps: ? poll rxrdy flag in ac97 controller channel x status register (cxsr). x being one of the 2 channels. ? read data from ac97 controller channel x read holding register. the application can also wait for an interrupt notice in order to read data from cxrhr. the inter- rupt remains active until rxrdy is cleared by reading cxsr. the rxrdy flag in cxsr is set automatically when data is received in the channel x shift regis- ter. data is then shifted to cxrhr. figure 26-6. audio transfer (pcm l front, pcm r front) on channel x if the previously received data has not been read by the application, the new data overwrites the data already waiting in cxrhr, therefore the ovrun flag in cx sr is raised. the application can either poll the ovrun flag in cxsr or wait for an interrupt notice. the interrupt remains active until the ovrun fl ag in cxsr is set. the ac97 controller can also be used in sound recording devices in association with an ac97 codec. the ac97 controller may also be exposed to heavy pcm transfers. the application can use the dmac connected to both channels in order to reduce processor overhead and increase performance especially under an operating system. the dmac receive counter values must be equal to the number of pcm samples to be received. when more than one timeslot is assigned to a channel using dma, the different timeslot sam- ples will be interleaved. 26.7.3.5 ac97 input frame the ac97 controller receives a thirteen slot frame on the ac-link sent by the ac97 codec. the first slot (tag slot or slot 0) fl ags the validity of the entire frame and the validity of each slot; whether a slot carries valid data or not. slots 1 and 2 are used if the application requires status informations from ac97 codec. slots [3:12] are used according to ac97 controller output channel assignment register (ica) content. the ac97 controller will not receive any data from any slot if ica is not assigned to a channel in input. slot # ac97fs 0123 4 56 7 8 9 1011 12 rxrdycx (ac97c_sr) read access to ac97c_rhrx ac97rx (codec output) tag status addr status data pcm left pcm right line 1 dac pcm mic rsved rsved rsved line 2 adc hset adc io status
445 32015a?avr32?02/07 AT32AP7001 26.7.3.6 configuring and using interrupts instead of polling flags in ac97 controller global status register (sr) and in ac97 controller channel x status register (cxsr), the applicatio n can wait for an interr upt notice. the following steps show how to configure and use interrupts correctly: ? set the interruptible flag in ac97 controller channel x mode register (cxmr). ? set the interruptible event and channel event in ac97 controller interrupt enable register (ier). the interrupt handler must read both ac97 controller global status register (sr) and ac97 controller interrupt mask register (imr) and and them to get the real interrupt source. further- more, to get which event was activated, the interrupt handler has to read ac97 controller channel x status register (cxsr), x being the channel whose event triggers the interrupt. the application can disable event interrupts by writing in ac97 controlle r interrupt disable reg- ister (idr). the ac97 controller interrupt mask register (imr) shows which event can trigger an interrupt and which one cannot. 26.7.3.7 endianness endianness can be managed automatically for each channel, except for the codec channel, by writing to channel endianness mode (cem) in cxmr. this enables transferring data on ac-link in little endian format without any additional operation. 26.7.3.8 to transmit a word stored in little endian format on ac-link word to be written in ac97 co ntroller channel x transmit hold ing register (cxthr) (as it is stored in memory or mi croprocessor register). word stored in channel x transmit holding register (ac97c_cxthr) (data to transmit) . data transmitted on appropriate slot: data[19:0] = {byte1[3:0], byte2[7:0], byte3[7:0]}. 26.7.3.9 to transmit a halfword stored in little endian format on ac-link halfword to be written in ac97 controller ch annel x transmit hold ing register (cxthr). halfword stored in ac97 cont roller channel x transmit hold ing register (cxthr) (data to transmit). data emitted on related slot: data[19:0] = {byte1[7:0], byte0[7:0], 0x0}. 31 24 23 16 15 8 7 0 byte3[7:0] byte2[7:0] byte1[7:0] byte0[7:0] 31 24 23 20 19 16 15 8 7 0 ? ? byte1[3:0] byt e2[7:0] byte3[7:0] 31 24 23 16 15 8 7 0 ? ? byte0[7:0] byte1[7:0] 31 24 23 16 15 8 7 0 ? ? byte1[7:0] byte0[7:0]
446 32015a?avr32?02/07 AT32AP7001 26.7.3.10 to transmit a10-bit sample stored in little endian format on ac-link halfword to be written in ac97 controller ch annel x transmit hold ing register (cxthr). halfword stored in ac97 cont roller channel x transmit hold ing register (cxthr) (data to transmit). data emitted on related slot: data[19:0] = {byte1[1:0], byte0[7:0], 0x000}. 26.7.3.11 to receive word transfers data received on appropriate slot: data[19:0] = {byte2[3:0], byte1[7:0], byte0[7:0]}. word stored in ac97 co ntroller channel x receiv e holding register (cxrhr) (received data) . data is read from ac97 controller channel x receive holding register (cxrhr) when channel x data size is greater than 16 bits and when little endian mode is enabled (data written to memory). 26.7.3.12 to receive halfword transfers data received on appropriate slot: data[19:0] = {byte1[7:0], byte0[7:0], 0x0 }. halfword stored in ac97 controller channel x receive holding register (cxrhr) (received data). data is read from ac97 controller channel x receive holding register (cxrhr) when data size is equal to 16 bits and when little endian mode is enabled. 26.7.3.13 to receiv e 10-bit samples data received on appropriate slot: data[19:0] = {byte1[1:0], byte0[7:0], 0x000}. halfword stored in ac97 controller channel x receive hold ing register (cxrhr) (received data) 31 24 23 16 15 8 7 0 ? ? byte0[7:0] {0x00, byte1[1:0]} 31 24 23 16 15 10 9 8 7 0 ??? byte1 [1:0] byte0[7:0] 31 24 23 20 19 16 15 8 7 0 ? ? byte2[3:0] byt e1[7:0] byte0[7:0] 31 24 23 16 15 8 7 0 byte0[7:0] byte1[7:0] {0x0, byte2[3:0]} 0x00 31 24 23 16 15 8 7 0 ? ? byte1[7:0] byte0[7:0] 31 24 23 16 15 8 7 0 ? ? byte0[7:0] byte1[7:0] 31 24 23 16 15 10 9 8 7 0 ??? byte1 [1:0] byte0[7:0]
447 32015a?avr32?02/07 AT32AP7001 data read from ac97 controller channel x receive holding regist er (cxrhr) when data size is equal to 10 bits and when little endian mode is enabled. 26.7.4 variable sample rate the problem of variable sample rate can be su mmarized by a simple example. when passing a 44.1 khz stream across the ac-link, for every 480 audio output frames that are sent across, 441 of them must contain valid sample data. the new ac97 standard approach calls for the addition of ?on-demand? slot request flags. the ac97 codec examines its sample rate control register, the state of its fifos, and the incoming sdata_out tag bits (slot 0) of each output frame and then determines which slotreq bits to set acti ve (low). these bits are passed from the ac97 codec to the ac97 controller in slot 1/slotreq in every audio input frame. each time the ac97 controller sees one or more of the newly defined slot request flags set active (low) in a given audio input frame, it must pass along the next pcm sample for the corresponding slot(s) in the ac-link output frame that immediately follows. the variable sample rate mode is enabled by performing the following steps: ? setting the vra bit in the ac97 controller mode register (mr). ? enable variable rate mode in the ac97 codec by performing a transfer on the codec channel. slot 1 of the input frame is automatically interpreted as slotreq signaling bits. the ac97 con- troller will automatically fill the ac tive slots according to both sl otreq and oca register in the next transmitted frame. 26.7.5 power management 26.7.5.1 powering down the ac-link the ac97 codecs can be placed in low power mo de. the application can bring ac97 codec to a power down state by performing sequential writes to ac97 codec powerdown register . both the bit clock (clock delivered by ac97 codec, sclk) and the input line (sdi) are held at a logic low voltage level. this puts ac 97 codec in power down state while all its registers are still hold- ing current values. without the bit clock, the ac-link is completely in a power down state. the ac97 controller should not attempt to pl ay or capture audio data until it has awakened ac97 codec. to set the ac97 codec in low power mode, the pr4 bit in the ac97 codec powerdown register (codec address 0x26) must be set to 1. then the primary codec drives both bitclk and sdi to a low logic voltage level. the following operations must be done to put ac97 codec in low power mode: ? disable channel a clearing cen in the camr register. ? disable channel b clearing cen field in the cbmr register. ? write 0x2680 value in the cothr register. ? poll the txempty flag in cxsr registers for the 2 channels. at this point ac97 code c is in low power mode. 31 24 23 16 15 8 7 3 1 0 ? ? byte0[7:0] 0x00 byte1 [1:0]
448 32015a?avr32?02/07 AT32AP7001 26.7.5.2 waking up the ac-link there are two methods to bring the ac-link out of low power mode. regardless of the method, it is always the ac97 controller that performs the wake-up. 26.7.5.3 wake-up tiggered by the ac97 controller the ac97 controller can wake up the ac97 codec by issuing either a cold or a warm reset. the ac97 controller can also wake up the ac97 codec by asserting sync signal, however this action should not be performed for a minimum period of four audio frames following the frame in which the powerdown was issued. 26.7.5.4 wake-up triggered by the ac97 codec this feature is implemented in ac97 modem c odecs that need to report events such as caller- id and wake-up on ring. the ac97 codec can drive sdi signal from low to high level and holding it high until the control- ler issues either a cold or a warm reset. the sdi rising edge is asynchronously (regarding sync) detected by the ac97 controller. if wkup bit is enabled in imr register, an interrupt is triggered that wakes up the ac97 controller which should then immediately issue a cold or a warm reset. if the processor needs to be awakened by an exte rnal event, the sdi signal must be externally connected to the wakeup entry of the system controller. figure 26-7. ac97 power-down/up sequence ac97ck ac97fs tag write to 0x26 data pr4 power down frame sleep state tag write to 0x26 data pr4 wake event warm reset new audio frame tag slot1 slot2 ac97tx ac97rx tag slot1 slot2
449 32015a?avr32?02/07 AT32AP7001 26.7.5.5 ac97 codec reset there are three ways to reset an ac97 codec. 26.7.5.6 cold ac97 reset a cold reset is generated by asserting the reset signal low for the minimum specified time (depending on the ac97 codec) and then by de-a sserting reset high. bitclk and sync is reactivated and all ac97 codec registers are set to their default power-on values. transfers on ac-link can resume. the reset signal will be controlled via a pio line. th is is how an applicat ion should perform a cold reset: ? clear and set ena flag in the mr register to reset the ac97 controller ? clear pio line output cont rolling the ac97 reset signal ? wait for the minimum specified time ? set pio line output contro lling the ac97 reset signal bitclk, the clock provided by ac97 codec, is detected by the controller. 26.7.5.7 warm ac97 reset a warm reset reactivates the ac-link without alteri ng ac97 codec registers. a warm reset is sig- naled by driving ac97fx signal high for a minimum of 1us in the absence of bitclk. in the absence of bitclk, ac97fx is treated as an a synchronous (regarding ac97fx) input used to signal a warm reset to ac97 codec. this is the right way to perform a warm reset: ? set wrst in the mr register. ? wait for at least 1us ? clear wrst in the mr register. the application can check that operations have resumed by checking sof flag in the sr regis- ter or wait for an interrupt notice if sof is enabled in imr.
450 32015a?avr32?02/07 AT32AP7001 26.8 ac97 controller (a c97c) user interface table 26-4. register mapping offset register register name access reset 0x0-0x4 reserved ? ? ? 0x8 mode register mr read/write 0x0 0xc reserved ? ? ? 0x10 input channel assignment register ica read/write 0x0 0x14 output channel assignment register oca read/write 0x0 0x18-0x1c reserved ? ? ? 0x20 channel a receive holding register carhr read 0x0 0x24 channel a transmit holding register cathr write ? 0x28 channel a status register casr read 0x0 0x2c channel a mode register camr read/write 0x0 0x30 channel b receive holding register cbrhr read 0x0 0x34 channel b transmit holding register cbthr write ? 0x38 channel b status register cbsr read 0x0 0x3c channel b mode register cbmr read/write 0x0 0x40 codec receive holding register corhr read 0x0 0x44 codec transmit holding register cothr write ? 0x48 codec status register cosr read 0x0 0x4c codec mode register comr read/write 0x0 0x50 status register sr read 0x0 0x54 interrupt enable register ier write ? 0x58 interrupt disable register idr write ? 0x5c interrupt mask register imr read 0x0 0x60-0xfb reserved ? ? ?
451 32015a?avr32?02/07 AT32AP7001 26.8.1 ac97 controller mode register name: mr access type: read-write ? vra: variable rate (for data slots 3-12) 0: variable rate is inactive. (48 khz only) 1: variable rate is active. ? wrst: warm reset 0: warm reset is inactive. 1: warm reset is active. ? ena: ac97 controller global enable 0: no effect. ac97 function as well as access to other ac97 controller registers are disabled. 1: activates the ac97 function. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?????vrawrstena
452 32015a?avr32?02/07 AT32AP7001 26.8.2 ac97 controller input channel assignment register register name :ica access type : read/write ? chidx: channel id for the input slot x 31 30 29 28 27 26 25 24 ? ? chid12 chid11 23 22 21 20 19 18 17 16 chid10 chid9 chid8 15 14 13 12 11 10 9 8 chid8 chid7 chid6 chid5 76543210 chid5 chid4 chid3 chidx selected receive channel 0x0 none. no data will be received during this slot x 0x1 channel a data will be received during this slot time. 0x2 channel b data will be received during this slot time
453 32015a?avr32?02/07 AT32AP7001 26.8.3 ac97 controller output channel assignment register register name :oca access type : read/write ? chidx: channel id for the output slot x 31 30 29 28 27 26 25 24 ? ? chid12 chid11 23 22 21 20 19 18 17 16 chid10 chid9 chid8 15 14 13 12 11 10 9 8 chid8 chid7 chid6 chid5 76543210 chid5 chid4 chid3 chidx selected transmit channel 0x0 none. no data will be transmitted during this slot x 0x1 channel a data will be transferred during this slot time. 0x2 channel b data will be transferred during this slot time
454 32015a?avr32?02/07 AT32AP7001 26.8.4 ac97 controller codec channel receive holding register register name : corhr access type : read-only ?sdata: status data data sent by the codec in the third ac97 input frame slot (slot 2). 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 sdata 76543210 sdata
455 32015a?avr32?02/07 AT32AP7001 26.8.5 ac97 controller codec channel transmit holding register register name :cothr access type : write-only ? read: read/write command 0: write operation to the codec r egister indexed by the caddr address. 1: read operation to the codec register indexed by the caddr address. this flag is sent during the second ac97 frame slot ? caddr: codec control register index data sent to the codec in the second ac97 frame slot. ? cdata: command data data sent to the codec in the third ac97 frame slot (slot 2). 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 read caddr 15 14 13 12 11 10 9 8 cdata 76543210 cdata
456 32015a?avr32?02/07 AT32AP7001 26.8.6 ac97 controller channel a, channel b receive holding register register name : carhr, cbrhr access type : read-only ? rdata: receive data received data on channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???? rdata 15 14 13 12 11 10 9 8 rdata 76543210 rdata
457 32015a?avr32?02/07 AT32AP7001 26.8.7 ac97 controller channel a, channel b transmit holding register register name : cathr, cbthr access type : write-only ? tdata: transmit data data to be sent on channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???? tdata 15 14 13 12 11 10 9 8 tdata 76543210 tdata
458 32015a?avr32?02/07 AT32AP7001 26.8.8 ac97 controller channel a status register register name : casr access type : read-only 26.8.9 ac97 controller channel b status register register name : cbsr access type : read-only 26.8.10 ac97 controller codec channel status register register name : cosr access type : read-only ? txrdy: channel transmit ready 0: data has been loaded in channel transmit register and is waiting to be loaded in the channel transmit shift register. 1: channel transmit register is empty. ? txempty: channel transmit empty 0: data remains in the channel transmit register or is currently transmitted from the channel transmit shift register. 1: data in the channel transmit register have been loaded in the channel transmit shift register and sent to the codec. ? rxrdy: channel receive ready 0: channel receive holding register is empty. 1: data has been received and loaded in channel receive holding register. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? unrun txempty txrdy 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? unrun txempty txrdy 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? - txempty txrdy
459 32015a?avr32?02/07 AT32AP7001 ? ovrun: receive overrun automatically cleared by a processor read operation. 0: no data has been loaded in the channel receive holding register while previous data has not been read since the last read of the status register. 1: data has been loaded in the channel receive holding regi ster while previous data has not yet been read since the last read of the status register.
460 32015a?avr32?02/07 AT32AP7001 26.8.11 ac97 controller channel a mode register register name :camr access type : read/write ? dmaen: dma enable 0: disable dma transfers for this channel. 1: enable dma transfers for this channel using dmac. ? cem: channel a endian mode 0: transferring data through channel a is straight forward (big endian). 1: transferring data through channel a from/to a memory is performed with from/to little endian format translation. ? size: channel a data size size encoding note: each time slot in the data phase is 20 bit long. for example, if a 16-bit sample stream is being played to an ac 97 dac, t he first 16 bit positions are presented to the dac msb-justified. they ar e followed by the next four bit positions that the ac97 control ler fills with zeroes. this process ensures that the least significant bits do not introduce any dc biasing, regardless of the impl e- mented dac?s resolution (16-, 18-, or 20-bit). ? cen: channel a enable 0: data transfer is disabled on channel a. 1: data transfer is enabled on channel a. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? dmaen cen ? ? cem size 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? unrun txempty txrdy size selected channel 0x0 20 bits 0x1 18bits 0x2 16 bits 0x3 10 bits
461 32015a?avr32?02/07 AT32AP7001 26.8.12 ac97 controller channel b mode register register name :cbmr access type : read/write ? dmaen: dma enable 0: disable dma transfers for this channel. 1: enable dma transfers for this channel using dmac. ? cem: channel b endian mode 0: transferring data through channel b is straight forward (big endian). 1: transferring data through channel b from/to a memory is performed with from/to little endian format translation. ? size: channel b data size size encoding note: each time slot in the data phase is 20 bit long. for example, if a 16-bit sample stream is being played to an ac 97 dac, t he first 16 bit positions are presented to the dac msb-justified. they ar e followed by the next four bit positions that the ac97 control ler fills with zeroes. this process ensures that the least significant bits do not introduce any dc biasing, regardless of the impl e- mented dac?s resolution (16-, 18-, or 20-bit). ? cen: channel b enable 0: data transfer is disabled on channel b. 1: data transfer is enabled on channel b. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? dmaen cen ? ? cem size 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? unrun txempty txrdy size selected channel 0x0 20 bits 0x1 18bits 0x2 16 bits 0x3 10 bits
462 32015a?avr32?02/07 AT32AP7001 26.8.13 ac97 controller codec channel mode register register name : comr access type : read/write ? txrdy: channel transmit ready interrupt enable ? txempty: channel transmit empty interrupt enable ? rxrdy: channel receive ready interrupt enable ? ovrun: receive overrun interrupt enable 0: read: the corresponding interrupt is disabled. write: disables the corresponding interrupt. 1: read: the corresponding interrupt is enabled. write: enables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ovrun rxrdy ? - txempty txrdy
463 32015a?avr32?02/07 AT32AP7001 26.8.14 ac97 controller status register register name :sr access type : read-only wkup and sof flags in sr register are automat ically cleared by a processor read operation. ? sof: start of frame 0: no start of frame has been detected since the last read of the status register. 1: at least one start of frame has been detected since the last read of the status register. ? wkup: wake up detection 0: no wake-up has been detected. 1: at least one rising edge on sdata_in has been asynchr onously detected. that means ac97 codec has notified a wake-up. ? coevt: codec channel event a codec channel event occurs when cosr and comr is not 0. coevt flag is automatically cleared when the channel event condition is cleared. 0: no event on the codec channel has been detected since the last read of the status register. 1: at least one event on th e codec channel is active. ? caevt: channel a event a channel a event occurs when casr and camr is not 0. ca evt flag is automatically cleared when the channel event condition is cleared. 0: no event on the channel a has been detected since the last read of the status register. 1: at least one event on the channel a is active. ? cbevt: channel b event a channel b event occurs when cbsr and cbmr is not 0. cb evt flag is automatically cleared when the channel event condition is cleared. 0: no event on the channel b has been detected since the last read of the status register. 1: at least one event on the channel b is active. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? cbevt caevt coevt wkup sof
464 32015a?avr32?02/07 AT32AP7001 26.8.15 ac97 controller interrupt enable register register name :ier access type : write-only ? sof: start of frame ?wkup: wake up ? coevt: codec event ? caevt: channel a event ? cbevt: channel b event 0: no effect. 1: enables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? cbevt caevt coevt wkup sof
465 32015a?avr32?02/07 AT32AP7001 26.8.16 ac97 controller interrupt disable register register name :idr access type : write-only ? sof: start of frame ?wkup: wake up ? coevt: codec event ? caevt: channel a event ? cbevt: channel b event 0: no effect. 1: disables the corresponding interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? cbevt caevt coevt wkup sof
466 32015a?avr32?02/07 AT32AP7001 26.8.17 ac97 controller interrupt mask register register name :imr access type : read-only ? sof: start of frame ?wkup: wake up ? coevt: codec event ? caevt: channel a event ? cbevt: channel b event 0: the corresponding interrupt is disabled. 1: the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? ? cbevt caevt coevt wkup sof
467 32015a-avr32-02/07 AT32AP7001 27. audio dac - (dac) 27.1 features ? digital stereo dac ? oversampled d/a conversion architecture ? oversampling ratio fixed 128x ? fir equalization filter ? digital interpolation filter: comb4 ? 3rd order sigma-delta d/a converters ? digital bitstream outputs ? parallel interface ? connected to dma controller for backgrou nd transfer without cpu intervention 27.2 description the audio dac converts a 16-bit sample value to a digital bitstream with an average value pro- portional to the sample value. two channels are supported, making the audio dac particularly suitable for stereo audio. each channel has a pair of complementary digital outputs, dacn and dacn_n, which can be connected to an external high input impedance amplifier. the audio dac is compromised of two 3rd order sigma delta d/a converter with an oversam- pling ratio of 128. the samples are upsampled with a 4th order sinc interpolation filter (comb4) before being input to the sigmal delta modulator. in order to compensate for the pass band fre- quency response of the interpolation filter and flatten the overall frequency response, the input to the interpolation filter is first filtered with a simple 3-tap fir filter.the total frequency response of the equalization fir filter and the interpolation filter is given in figure 27-2 on page 479 . the digital output bitstreams from the sigma delta modulators should be low-pass filtered to remove high frequency noise inserted by the modulation process. the output dacn and dacn_n should be as ideal as possible before filtering, to achieve the best snr quality. the output can be connected to a class d amplifier output stage, or it can be low pass filtered and connected to a high input impedance amplifier. a simple 1st order or higher low pass filter that filters all the frequencies above 50 khz should be adequate.
468 32015a-avr32-02/07 AT32AP7001 27.3 block diagram figure 27-1. functional block diagram 27.4 pin name list 27.5 product dependencies 27.5.1 i/o lines the output pins used for the output bitstream from the audio dac may be multiplexed with pio lines. before using the audio dac, the pio controller must be configured in order for the audio dac i/o lines to be in audio dac peripheral mode. 27.5.2 power management the pb-bus clock to the audio dac is generated by the power manager. before using the audio dac, the programmer must ensure that the audio dac clock is enabled in the power manager. table 27-1. i/o lines description pin name pin description type data0 output from audio dac channel 0 output data1 output from audio dac channel 1 output datan0 inverted output from audio dac channel 0 output datan1 inverted output from audio dac channel 1 output clock generator equalization fir comb (int=128) sigma-delta da-mod equalization fir comb (int=128) sigma-delta da-mod bit_clk bit_out1 bit_out2 clk sample_clk din1[15:0] din2[15:0] audiodac
469 32015a-avr32-02/07 AT32AP7001 27.5.3 clock management the audio dac needs a separate clock for the d/a conversion operation. this clock should be set up in the generic clock register in the po wer manager. the frequency of this clock must be 256 times the frequency of the desired samplerate (f s ). for f s =48khz this means that the clock must have a frequency of 12.288mhz. 27.5.4 interrupts the audio dac interface has an interrupt line connected to the interrupt controller. in order to handle interrupts, the interrupt controller must be programmed before configuring the audio dac. all audio dac interrupts can be enabled/disab led by writing to th e audio dac interrupt enable/disable registers. each pending and unm asked audio dac interrupt will assert the interrupt line. the audio dac interrupt service routine can get the interrupt source by reading the interrupt status register. 27.5.5 dma the audio dac is connected to the dma controller. the dma controller can be programmed to automatically transfer samples to the audio da c sample data register (sdr) when the audio dac is ready for new samples. this enables t he audio dac to operate without any cpu inter- vention such as polling the inte rrupt status register (isr) or using inte rrupts. see the dma controller documentation for details on how to setup dma transfers. 27.6 functional description in order to use the audio dac the product dependencies given in section 27.5 on page 468 must be resolved. particular attention should be given to the configuration of clocks and i/o lines in order to ensure correct operation of the audio dac. the audio dac is enabled by writing the enable bit in the audio dac control register (cr). the two 16-bit sample values for channel 0 and 1 can then be written to the least and most sig- nificant halfword of the sample data register (sdr), respectively. the tx_ready bit in the interrupt status register (isr) will be set whenever the dac is ready to receive a new sample. a new sample value should be written to sdr be fore 256 dac clock cycles, or an underrun will occur, as indicated by the underrun status flags in isr. isr is clear ed when read, or when writing one to the corresponding bits in the interrupt clear register (icr). for interrupt-based operation, the relevant interrupts must be enabled by writing one to the cor- responding bits in the interrupt enable register (ier). interrupts can be disabled by the interrupt disable register (idr), and active interrupts are indicated in the read-only interrupt mask regis- ter (imr). the audio dac can also be configured for peri pheral dma access, in which case only the enable bit in the control register needs to be set in the audio dac module. 27.6.1 equalization filter the equalization filter is a simple 3-tap fir filter. the purpose of this filter is to compensate for the pass band frequency response of the sinc interpolation filter. the equalization filter makes the pass band response more flat and moves the -3db corner a little higher.
470 32015a-avr32-02/07 AT32AP7001 27.6.2 interpolation filter the interpolation filter interpolates from f s to 128f s . this filter is a 4th order cascaded integrator- comb filter, and the basic building blocks of this filter is a comb part and an integrator part. 27.6.3 sigma delta modulator this part is a 3rd order sigma delta modulator co nsisting of three differentiators (delta blocks), three integrators (sigma blocks) and a one bit quantizer. the purpose of the integrators is to shape the noise, so that the noise is reduces in the band of interest and increased at the higher frequencies, where it can be filtered. 27.6.4 data format input data is on two?s complement format.
471 32015a-avr32-02/07 AT32AP7001 27.7 audio dac user interface table 27-2. register mapping offset register register name access reset 0x0 sample data register sdr read/write 0x0 0x4 reserved - - - 0x8 control register cr read/write 0x0 0xc interrupt mask register imr read 0x0 0x10 interrupt enable register ier write - 0x14 interrupt disable register idr write - 0x18 interrupt clear register icr write - 0x1c interrupt status register isr read 0x0
472 32015a-avr32-02/07 AT32AP7001 27.7.1 audio dac sample data register name: sdr access type: read-write ? channel0: sample data for channel 0 signed 16-bit sample data for channel 0. when the swap bit in the dac control register (cr) is set writing to the sample data register (sdr) will cause the values writ ten to channel0 and ch annel1 to be swapped. ? channel1: sample data for channel 1 signed 16-bit sample data for channel 1. when the swap bit in the dac control register (cr) is set writing to the sample data register (sdr) will cause the values writ ten to channel0 and ch annel1 to be swapped. 31 30 29 28 27 26 25 24 channel1 23 22 21 20 19 18 17 16 channel1 15 14 13 12 11 10 9 8 channel0 76543210 channel0
473 32015a-avr32-02/07 AT32AP7001 27.7.2 audio dac control register name: cr access type: read-write ? swap: swap channels 0: the channel0 and channel1 samples will not be swapped when writing the audio dac sample data register (sdr). 1: the channel0 and channel1 samples will be swapped when writing the audio dac sample data register (sdr). ? en: enable audio dac 0: audio dac is disabled. 1: audio dac is enabled. 31 30 29 28 27 26 25 24 enswap------ 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
474 32015a-avr32-02/07 AT32AP7001 27.7.3 audio dac interrupt mask register name: imr access type: read-only ? underrun: underrun interrupt mask 0: the audio dac underrun interrupt is disabled. 1: the audio dac underrun interrupt is enabled. ? tx_ready: tx ready interrupt mask 0: the audio dac tx ready interrupt is disabled. 1: the audio dac tx ready interrupt is enabled. 31 30 29 28 27 26 25 24 --tx_readyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
475 32015a-avr32-02/07 AT32AP7001 27.7.4 audio dac interrupt enable register name: ier access type: write-only ? underrun: underrun interrupt enable 0: no effect. 1: enables the audio dac underrun interrupt. ? tx_ready: tx ready interrupt enable 0: no effect. 1: enables the audio dac tx ready interrupt. 31 30 29 28 27 26 25 24 --tx_readyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
476 32015a-avr32-02/07 AT32AP7001 27.7.5 audio dac interrupt disable register name: idr access type: write-only ? underrun: underrun interrupt disable 0: no effect. 1: disable the audio da c underrun interrupt. ? tx_ready: tx ready interrupt disable 0: no effect. 1: disable the audio dac tx ready interrupt. 31 30 29 28 27 26 25 24 --tx_readyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
477 32015a-avr32-02/07 AT32AP7001 27.7.6 audio dac interrupt clear register name: icr access type: write-only ? underrun: underrun interrupt clear 0: no effect. 1: clear the audio dac underrun interrupt. ? tx_ready: tx ready interrupt clear 0: no effect. 1: clear the audio dac tx ready interrupt. 31 30 29 28 27 26 25 24 --tx_readyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
478 32015a-avr32-02/07 AT32AP7001 27.7.7 audio dac interrupt status register name: isr access type: read-only ? underrun: underrun interrupt status 0: no audio dac underrun has occured since t he last time isr was read or since reset. 1: at least one audio dac underrun has occured since the last time isr was read or since reset. ? tx_ready: tx ready interrupt status 0: no audio dac tx ready has occuredt since the last time isr was read. 1: at least one audio dac tx ready has occuredt since the last time isr was read. 31 30 29 28 27 26 25 24 --tx_readyunderrun---- 23 22 21 20 19 18 17 16 -------- 15 14 13 12 11 10 9 8 -------- 76543210 --------
479 32015a-avr32-02/07 AT32AP7001 27.8 frequency response figure 27-2. frequecy response, eq-fir+comb 4 0 1 2 3 4 5 6 7 8 9 10 x 10 4 -6 0 -5 0 -4 0 -3 0 -2 0 -1 0 0 10
480 32015a?avr32?02/07 AT32AP7001 28. static memory controller (smc) rev: 1.0.4.0 28.1 features ? 6 chip selects available ? 64-mbyte address space per chip select ? 8-, 16- or 32-bit data bus ? word, halfword, byte transfers ? byte write or by te select lines ? programmable setup, pulse and hold ti me for read signals per chip select ? programmable setup, pulse and hold time for write signals per chip select ? programmable data float time per chip select ? compliant with lcd module ? external wait request ? automatic switch to slow clock mode ? asynchronous read in page mode supporte d: page size ranges from 4 to 32 bytes 28.2 description the static memory controller (smc) generates the signals that control the access to the exter- nal memory devices or peripheral devices. it has 6 chip selects and a 26-bit address bus. the 32-bit data bus can be configured to interface with 8-, 16-, or 32-bit external devices. separate read and write control signals allow for direct memory and peripheral interfacing. read and write signal waveforms are fully parametrizable. the smc can manage wait requests from external devices to extend the current access. the smc is provided with an automatic slow clock mode. in slow clock mode, it switches from user- programmed waveforms to slow-rate specific waveforms on read and write signals. the smc supports asynchronous burst read in page mode access for page size up to 32 bytes.
481 32015a?avr32?02/07 AT32AP7001 28.3 block diagram figure 28-1. smc block diagram bus matrix peripheral bus ncs[7:0] nwr0/nwe nwait smc pio controller a0/nbs0 nrd nwr1/nbs1 a1/nwr2/nbs2 nwr3/nbs3 a[25:2] user interface pmc mck d[31:0] smc chip select
482 32015a?avr32?02/07 AT32AP7001 28.4 i/o lines description 28.5 multiplexed signals table 28-1. i/o line description name description type active level ncs[7:0] static memory controller chip select lines output low nrd read signal output low nwr0/nwe write 0/write enable signal output low a0/nbs0 address bit 0/byte 0 select signal output low nwr1/nbs1 write 1/byte 1 select signal output low a1/nwr2/nbs2 address bit 1/write 2/byte 2 select signal output low nwr3/nbs3 write 3/byte 3 select signal output low a[25:2] address bus output d[31:0] data bus i/o nwait external wait signal input low table 28-2. static memory controller (smc) multiplexed signals multiplexed signal s related function nwr0 nwe byte-write or byte-select access, see ?bat - byte write or byte select access? on page 484 a0 nbs0 8-bit or 16-/32-bit data bus, see ?data bus width? on page 484 nwr1 nbs1 byte-write or byte-select access see ?bat - byte write or byte select access? on page 484 a1 nwr2 nbs2 8-/16-bit or 32-bit data bus, see ?data bus width? on page 484 . byte-write or byte-select access, see ?bat - byte write or byte select access? on page 484 nwr3 nbs3 byte-write or byte-select access see ?bat - byte write or byte select access? on page 484
483 32015a?avr32?02/07 AT32AP7001 28.6 application example 28.6.1 hardware interface figure 28-2. smc connections to st atic memory devices 28.7 product dependencies 28.7.1 i/o lines the pins used for interfacing the static memory controller may be multiplexed with the pio lines. the programmer must first program the pio controller to assign the static memory con- troller pins to their peripheral function. if i/o lines of the smc are not used by the application, they can be used for other purposes by the pio controller. static memory controller d0-d31 a2 - a25 a0/nbs0 nwr0/nwe nwr1/nbs1 a1/nwr2/nbs2 nwr3/nbs3 128k x 8 sram d0 - d7 a0 - a16 oe we cs d0 - d7 d8-d15 a2 - a18 128k x 8 sram d0-d7 cs d16 - d23 d24-d31 128k x 8 sram d0-d7 cs nwr1/nbs1 nwr3/nbs3 nrd nwr0/nwe 128k x 8 sram d0 - d7 oe we cs nrd a1/nwr2/nbs2 ncs0 ncs1 ncs2 ncs3 ncs4 ncs5 ncs6 ncs7 a2 - a18 a0 - a16 nrd oe we oe we nrd a2 - a18 a0 - a16 a2 - a18 a0 - a16
484 32015a?avr32?02/07 AT32AP7001 28.8 external memory mapping the smc provides up to 26 address lines, a[25:0]. this allows each chip select line to address up to 64 mbytes of memory. if the physical memory device co nnected on one chip select is smaller than 64 mbytes, it wraps around and appears to be repeated within this space. the smc correctly handles any valid access to the memory devi ce within the page (see figure 28-1 ). a[25:0] is only significant for 8-bit memory, a[25:1 ] is used for 16-bit memory, a[25:2] is used for 32-bit memory. figure 28-3. memory connections for eight external devices 28.9 connection to external devices 28.9.1 data bus width a data bus width of 8, 16, or 32 bits can be selected for each chip select. this option is con- trolled by the field dbw in mode (mode register) for the corresponding chip select. figure 28-4 shows how to connect a 512k x 8-bit memory on ncs2. figure 28-5 shows how to connect a 512k x 16-bit memory on ncs2. figure 28-6 shows two 16-bit memories connected as a single 32-bit memory 28.9.2 bat - byte write or byte select access each chip select with a 16-bit or 32-bit data bus can operate with one of two different types of write access: byte write or byte select access. this is controll ed by the bat (bat = byte select access) field of the mode register for the corresponding chip select. nrd nwe a[25:0] d[31:0] 8 or 16 or 32 memory enable memory enable memory enable memory enable memory enable memory enable memory enable memory enable output enable write enable a[25:0] d[31:0] or d[15:0] or d[7:0] ncs3 ncs0 ncs1 ncs2 ncs7 ncs4 ncs5 ncs6 ncs[0] - ncs[7] smc
485 32015a?avr32?02/07 AT32AP7001 figure 28-4. memory connection for an 8-bit data bus figure 28-5. memory connection for a 16-bit data bus figure 28-6. memory connection for a 32-bit data bus smc a0 nwe nrd ncs[2] a0 write enable output enable memory enable d[7:0] d[7:0] a[18:2] a[18:2] a1 a1 smc nbs0 nwe nrd ncs[2] low byte enable write enable output enable memory enable nbs1 high byte enable d[15:0] d[15:0] a[19:2] a[18:1] a[0] a1 d[31:16] smc nbs0 nwe nrd ncs[2] nbs1 d[15:0] a[20:2] d[31:16] nbs2 nbs3 byte 0 enable write enable output enable memory enable byte 1 enable d[15:0] a[18:0] byte 2 enable byte 3 enable
486 32015a?avr32?02/07 AT32AP7001 28.9.2.1 byte write access byte write access supports one byte write signal per byte of the data bus and a single read signal. ? for 16-bit devices: the smc provides nwr0 and nwr1 write signals for respectively byte0 (lower byte) and byte1 (upper byte) of a 16-bit bus. one single read signal (nrd) is provided. byte write access is used to connect 2 x 8-bit devices as a 16-bit memory. ? for 32-bit devices: nwr0, nwr1, nwr2 and nwr3, are the write signals of byte0 (lower byte), byte1, byte2 and byte 3 (upper byte) respectively. one single read signal (nrd) is provided. byte write access is used to connect 4 x 8-bit devices as a 32-bit memory. byte write option is illustrated on figure 28-7 on page 486 . 28.9.2.2 byte select access in this mode, read/write operations can be enabled/disabled at a byte level. one byte-select line per byte of the data bus is provided. one nrd and one nwe signal control read and write. ? for 16-bit devices: the smc provides nbs0 and nbs1 selection signals for respectively byte0 (lower byte) and byte1 (upper byte) of a 16-bit bus. byte select access is used to connect one 16-bit device. ? for 32-bit devices: nbs0, nbs1, nbs2 and nbs3, are the selection signals of byte0 (lower byte), byte1, byte2 and byte 3 (upper byte) respectively. byte select access is used to connect two 16-bit devices. figure 28-8 on page 487 shows how to connect two 16-bit dev ices on a 32-bit data bus in byte select access mode, on ncs3. figure 28-7. connection of 2 x 8-bit devices on a 16-bit bus: byte write option smc a1 nwr0 nrd ncs[3] write enable read enable memory enable nwr1 write enable read enable memory enable d[7:0] d[7:0] d[15:8] d[15:8] a[24:2] a[23:1] a[23:1] a[0] a[0]
487 32015a?avr32?02/07 AT32AP7001 28.9.2.3 signal multiplexing depending on the bat, only the write signals or the byte select signals are used. to save ios at the external bus interface, control signals at the smc interface are multiplexed. table 28-3 on page 487 shows signal multiplexing depending on the data bus width and the byte access type. for 32-bit devices, bits a0 and a1 are unused. for 16-bit devices, bit a0 of address is unused. when byte select option is selected, nwr1 to nwr3 are unused. when byte write option is selected, nbs0 to nbs3 are unused. figure 28-8. connection of 2x16-bit data bus on a 32-bit data bus (byte select option) smc nwe nrd ncs[3] write enable read enable memory enable nbs0 d[15:0] d[15:0] d[31:16] a[25:2] a[23:0] write enable read enable memory enable d[31:16] a[23:0] low byte enable high byte enable low byte enable high byte enable nbs1 nbs2 nbs3 table 28-3. smc multiplexed signal translation signal name 32-bit bus 16-bit bus 8-bit bus device type 1x32-bit 2x16-bit 4 x 8- bit 1x16-bit 2 x 8-bit 1 x 8-bit byte access type (bat) byte select byte select byte write byte select byte write nbs0_a0 nbs0 nbs0 nbs0 a0 nwe_nwr0 nwe nwe nwr0 nwe nwr0 nwe nbs1_nwr1 nbs1 nbs1 nwr1 nbs1 nwr1 nbs2_nwr2_a1 nbs2 nbs2 nwr2 a1 a1 a1 nbs3_nwr3 nbs3 nbs3 nwr3
488 32015a?avr32?02/07 AT32AP7001 28.10 standard read and write protocols in the following sections, the byte access type is not considered. byte select lines (nbs0 to nbs3) always have the same timing as the a ad dress bus. nwe represents either the nwe sig- nal in byte select access type or one of the byte write lines (nwr0 to nwr3) in byte write access type. nwr0 to nwr3 have the same ti mings and protocol as nwe. in the same way, ncs represents one of the ncs[0..nb_cs-1] chip select lines. 28.10.1 read waveforms the read cycle is shown on figure 28-9 on page 488 . the read cycle starts with the address setting on the memory address bus, i.e.: {a[25:2], a1, a0} for 8-bit devices {a[25:2], a1} for 16-bit devices a[25:2] for 32-bit devices. figure 28-9. standard read cycle 28.10.1.1 nrd waveform the nrd signal is characterized by a setu p timing, a pulse width and a hold timing. 1. nrd_setup: the nrd setup time is defined as the setup of address before the nrd falling edge; 2. nrd_pulse: the nrd pulse length is the time between nrd falling edge and nrd rising edge; 3. nrd_hold: the nrd hold time is defined as the hold time of a ddress after the nrd rising edge. a[25:2] nbs0,nbs1, nbs2,nbs3, a0, a1 ncs nrd_setup nrd_pulse nrd_hold mck nrd d[31:0] ncs_rd_setup ncs_rd_pulse ncs_rd_hold nrd_cycle
489 32015a?avr32?02/07 AT32AP7001 28.10.1.2 ncs waveform similarly, the ncs signal can be divided into a setup time, pulse length and hold time: 1. ncs_rd_setup: the ncs setup time is defined as the setup time of address before the ncs falling edge. 2. ncs_rd_pulse: the ncs pulse length is the time between ncs falling edge and ncs rising edge; 3. ncs_rd_hold: the ncs hold time is defined as the hold time of address after the ncs rising edge. 28.10.1.3 read cycle the nrd_cycle time is defined as the total duration of the read cycle, i.e., from the time where address is set on the address bus to the point where address may change. the total read cycle time is equal to: nrd_cycle = nrd_setup + nrd_pulse + nrd_hold = ncs_rd_setup + ncs_rd_pulse + ncs_rd_hold all nrd and ncs timings are defined separately for each chip select as an integer number of master clock cycles. to ensure that the nrd and ncs timings are coherent, user must define the total read cycle instead of the hold timing. nrd_cycle implicitly defines the nrd hold time and ncs hold time as: nrd_hold = nrd_cycle - nrd setup - nrd pulse ncs_rd_hold = nrd_cycle - ncs_rd_setup - ncs_rd_pulse 28.10.1.4 null delay setup and hold if null setup and hold parame ters are programmed for nrd and/or ncs, nrd and ncs remain active continuously in case of consecutive read cycles in the same memory (see figure 28-10 ).
490 32015a?avr32?02/07 AT32AP7001 figure 28-10. no setup, no hold on nrd and ncs read signals 28.10.1.5 null pulse programming null pulse is not permitted. pulse must be at least set to 1. a null value leads to unpredictable behavior. 28.10.2 read mode as ncs and nrd waveforms are defined independently of one other, the smc needs to know when the read data is available on the data bus. the smc does not compare ncs and nrd tim- ings to know which signal rises first. the read_mode parameter indicates which signal (ncs or nrd) controls the read operation. this parameter resides in the mode register of the corre- sponding chip select. 28.10.2.1 read is controlled by nrd (read_mode = 1): figure 28-11 on page 491 shows the waveforms of a read operation of a typical asynchronous ram. the read data is available t pacc after the falling edge of nrd, and turns to ?z? after the ris- ing edge of nrd. in this case, the read_mode mu st be set to 1 (read is controlled by nrd), to indicate that data is available with the rising edge of nrd. the smc samples the read data internally on the rising edge of master clock that generates the rising edge of nrd, whatever the programmed waveform of ncs may be. mck nrd_pulse ncs_rd_pulse nrd_cycle nrd_pulse nrd_pulse ncs_rd_pulse ncs_rd_pulse nrd_cycle nrd_cycle a[25:2] nbs0,nbs1, nbs2,nbs3, a0, a1 ncs nrd d[31:0]
491 32015a?avr32?02/07 AT32AP7001 figure 28-11. read_mode = 1: data is sampled by smc before the rising edge of nrd 28.10.2.2 read is controlled by ncs (read_mode = 0) figure 28-12 on page 491 shows the typical read cycle of an lcd module. the read data is valid t pacc after the falling edge of the ncs signal and remains valid until the rising edge of ncs. data must be sampled when ncs is raised. in that case, the read_mode must be set to 0 (read is controlled by ncs): the smc internally samples the data on the rising edge of master clock that generates the rising edge of ncs, whatever the progra mmed waveform of nrd may be. figure 28-12. read_mode = 0: data is sampled by smc before the rising edge of ncs data sampling t pacc mck a[25:2] nbs0,nbs1, nbs2,nbs3, a0, a1 ncs nrd d[31:0] data sampling t pacc mck d[31:0] a[25:2] nbs0,nbs1, nbs2,nbs3, a0, a1 ncs nrd
492 32015a?avr32?02/07 AT32AP7001 28.10.3 write waveforms the write protocol is similar to the read protocol. it is depicted in figure 28-13 on page 492 . the write cycle starts with the address setting on the memory address bus. 28.10.3.1 nwe waveforms the nwe signal is characterized by a setu p timing, a pulse width and a hold timing. 1. nwe_setup: the nwe setup time is defined as the setup of address and data before the nwe falling edge; 2. nwe_pulse: the nwe pulse length is the time between nwe falling edge and nwe rising edge; 3. nwe_hold: the nwe hold time is defined as the hold time of address and data after the nwe rising edge. the nwe waveforms apply to all byte-write lines in byte write access mode: nwr0 to nwr3. 28.10.3.2 ncs waveforms the ncs signal waveforms in write operation are not the same that those applied in read opera- tions, but are separately defined: 1. ncs_wr_setup: the ncs setup time is defined as the setup time of address before the ncs falling edge. 2. ncs_wr_pulse: the ncs pulse length is the time between ncs falling edge and ncs rising edge; 3. ncs_wr_hold: the ncs hold time is defined as the hold time of address after the ncs rising edge. figure 28-13. write cycle a [25:2] nbs0, nbs1, nbs2, nbs3, a0, a1 ncs nwe_setup nwe_pulse nwe_hold mck nwe ncs_wr_setup ncs_wr_pulse ncs_wr_hold nwe_cycle
493 32015a?avr32?02/07 AT32AP7001 28.10.3.3 write cycle the write_cycle time is defined as the total durat ion of the write cycle, that is, from the time where address is set on the address bus to the point where address may change. the total write cycle time is equal to: nwe_cycle = nwe_setup + nwe_pulse + nwe_hold = ncs_wr_setup + ncs_wr_pulse + ncs_wr_hold all nwe and ncs (write) timings are defined separately for each chip select as an integer num- ber of master clock cycles. to ensure that the nwe and ncs timings are coherent, the user must define the total wr ite cycle instead of the hold timing. this implicitly defines the nwe hold time and ncs (write) hold times as: nwe_hold = nwe_cycle - nwe_setup - nwe_pulse ncs_wr_hold = nwe_cycle - ncs_wr_setup - ncs_wr_pulse 28.10.3.4 null delay setup and hold if null setup parameters are programmed for nwe and/or ncs, nwe and/or ncs remain active continuously in case of consecutive wr ite cycles in the same memory (see figure 28-14 on page 493 ). however, for devices that perform write operations on the rising edge of nwe or ncs, such as sram, either a setup or a hold must be programmed. figure 28-14. null setup and hold values of ncs and nwe in write cycle 28.10.3.5 null pulse programming null pulse is not permitted. pulse must be at least set to 1. a null value leads to unpredictable behavior. ncs mck nwe, nwr0, nwr1, nwr2, nwr3 d[31:0] nwe_pulse ncs_wr_pulse nwe_cycle nwe_pulse ncs_wr_pulse nwe_cycle nwe_pulse ncs_wr_pulse nwe_cycle a [25:2] nbs0, nbs1, nbs2, nbs3, a0, a1
494 32015a?avr32?02/07 AT32AP7001 28.10.4 write mode the write_mode parameter in the mode register of the corresponding chip select indicates which signal controls the write operation. 28.10.4.1 write is controlled by nwe (write_mode = 1): figure 28-15 on page 494 shows the waveforms of a write operation with write_mode set to 1. the data is put on the bus during the pulse and hold steps of the nwe signal. the internal data buffers are turned out after the nwe_setup time, and until the end of the write cycle, regardless of the programmed waveform on ncs. figure 28-15. write_mode = 1. the write op eration is controlled by nwe 28.10.4.2 write is controlled by ncs (write_mode = 0) figure 28-16 on page 495 shows the waveforms of a write operation with write_mode set to 0. the data is put on the bus during the pulse and hold steps of the ncs signal. the internal data buffers are turned out after the ncs_wr_setup time, and until the end of the write cycle, regardless of the programmed waveform on nwe. mck d[31:0] ncs a [25:2] nbs0, nbs1, nbs2, nbs3, a0, a1 nwe, nwr0, nwr1, nwr2, nwr3
495 32015a?avr32?02/07 AT32AP7001 figure 28-16. write_mode = 0. the write op eration is controlled by ncs 28.10.5 coding timing parameters all timing parameters are defined for one chip select and are grouped together in one smc_register according to their type. the setup register groups the definition of all setup parameters: ? nrd_setup, ncs_rd_setup, nwe_setup, ncs_wr_setup the pulse register groups the definition of all pulse parameters: ? nrd_pulse, ncs_rd_pulse, nwe_pulse, ncs_wr_pulse the cycle register groups the definition of all cycle parameters: ? nrd_cycle, nwe_cycle section 28-4 on page 495 shows how the timing parameters are coded and their permitted range. mck d[31:0] ncs nwe, nwr0, nwr1, nwr2, nwr3 a [25:2] nbs0, nbs1, nbs2, nbs3, a0, a1 table 28-4. coding and range of timing parameters coded value number of bits effective value permitted range coded value effective value setup [5:0] 6 128 x setup[5] + setup[4:0] 0 31 128 128+31 pulse [6:0] 7 256 x pulse[6] + pulse[5:0] 0 63 256 256+63 cycle [8:0] 9 256 x cycle[8:7] + cycle[6:0] 0 127 256 256+127 512 512+127 768 768+127
496 32015a?avr32?02/07 AT32AP7001 28.10.6 reset values of timing parameters section 28-5 on page 496 gives the default value of timing parameters at reset. 28.10.7 usage restriction the smc does not check the validity of the user-programmed parameters. if the sum of setup and pulse parameters is larger than the corresponding cycle parameter, this leads to unpredictable behavior of the smc. for read operations: null but positive setup and hold of address and nrd and/or ncs can not be guaranteed at the memory interface because of the propagation dela y of theses signals through external logic and pads. if positive setup and hold values must be verified, then it is strictly recommended to pro- gram non-null values so as to cover possible skews between address, ncs and nrd signals. for write operations: if a null hold value is programmed on nwe, the smc can guarantee a positive hold of address, byte select lines, and ncs signal after the rising edge of nwe. this is true for write_mode = 1 only. see ?early read wait state? on page 497 . for read and write operations: a null value for pulse parameters is forbidden and may lead to unpredictable behavior. in read and write cycles, the setup and hold time parameters are defined in reference to the address bus. for external devices that require setup and hold time between ncs and nrd sig- nals (read), or between ncs and nwe signals (write), these setup and hold times must be converted into setup and hold times in reference to the address bus. 28.11 automatic wait states under certain circumstances, the smc automatica lly inserts idle cycles between accesses to avoid bus contention or operation conflict. 28.11.1 chip select wait states the smc always inserts an idle cycle between 2 transfers on separate chip selects. this idle cycle ensures that there is no bus contention between the de-activation of one device and the activation of the next one. during chip select wait state, all control li nes are turned inactive: nbs0 to nbs3, nwr0 to nwr3, ncs[0..nb_cs-1], nrd lines are all set to 1. figure 28-17 on page 497 illustrates a chip select wait stat e between access on chip select 0 and chip select 2. table 28-5. reset values of timing parameters register reset value setup 0x01010101 all setup timings are set to 1 pulse 0x01010101 all pulse timings are set to 1 cycle 0x00030003 the read and write operation last 3 master clock cycles and provide one hold cycle write_mode 1 write is controlled with nwe read_mode 1 read is controlled with nrd
497 32015a?avr32?02/07 AT32AP7001 figure 28-17. chip select wait state between a read access on ncs0 and a write access on ncs2 28.11.2 early read wait state in some cases, the smc inserts a wait state cycle between a write access and a read access to allow time for the write cycle to end before the subsequent read cycle begins. this wait state is not generated in addition to a chip select wait state. the early read cycle thus only occurs between a write and read access to the same memory device (same chip select). an early read wait state is automatically inserted if at least one of the following conditions is valid: ? if the write controlling signal has no hold time and the read controlling signal has no setup time ( figure 28-18 on page 498 ). ? in ncs write controlled mode (write_mode = 0), if there is no hold timing on the ncs signal and the ncs_rd_setup parameter is set to 0, regardless of the read mode ( figure 28-19 on page 498 ). the write operation must end with a ncs rising edge. without an early read wait state, the write operation could not complete properly. ? in nwe controlled mode (write_mode = 1) and if there is no hold timing (nwe_hold = 0), the feedback of the write control signal is used to control address, data, chip select and byte select lines. if the external write control signal is not inactivated as expected due to load capacitances, an early read wait state is inserted and address, data and control signals are maintained one more cycle. see figure 28-20 on page 499 . a[25:2] nbs0, nbs1, nbs2, nbs3, a0,a1 ncs0 nrd_cycle chip select wait state nwe_cycle mck ncs2 nrd nwe d[31:0] read to write wait state
498 32015a?avr32?02/07 AT32AP7001 figure 28-18. early read wait state: write with no hold followed by read with no setup figure 28-19. early read wait state: ncs controlled write with no hold followed by a read with no ncs setup write cycle early read wait state mck nrd nwe read cycle no setup no hold d[31:0] nbs0, nbs1, nbs2, nbs3, a0, a1 a[25:2] write cycle (write_mode = 0) early read wait state mck nrd ncs read cycle (read_mode = 0 or read_mode = 1) no setup no hold d[31:0] nbs0, nbs1, nbs2, nbs3, a0,a1 a[25:2]
499 32015a?avr32?02/07 AT32AP7001 figure 28-20. early read wait state: nwe-controlled write with no hold followed by a read with one set-up cycle 28.11.3 reload user configuration wait state the user may change any of the configuration parameters by writing the smc user interface. when detecting that a new user configuration has been written in the user interface, the smc inserts a wait state before starting the next access. the so called ?reload user configuration wait state? is used by the smc to load the new set of parameters to apply to next accesses. the reload configuration wait state is not applied in addition to the chip select wait state. if accesses before and after re-programming the user interface are made to different devices (chip selects), then one single chip select wait state is applied. on the other hand, if accesses before and after writing the user interface are made to the same device, a reload configuration wait state is inserted, even if the change does not concern the current chip select. 28.11.3.1 user procedure to insert a reload configuration wait state, the smc detects a write access to any mode reg- ister of the user interface. if the user only mo difies timing registers (setup, pulse, cycle registers) in the user interface, he must validate the modification by writing the mode, even if no change was made on the mode parameters. 28.11.3.2 slow clock mode transition a reload configuration wait state is also inserted when the slow clock mode is entered or exited, after the end of the current transfer (see ?slow clock mode? on page 511 ). a [25:2] nbs0, nbs1, nbs2, nbs3, a0, a1 write cycle (write_mode = 1) early read wait state mck nrd internal write controlling signal external write controlling signal (nwe) d[31:0] read cycle (read_mode = 0 or read_mode = 1) no hold read setup = 1
500 32015a?avr32?02/07 AT32AP7001 28.11.4 read to write wait state due to an internal mechanism, a wait cycle is always inserted between consecutive read and write smc accesses. this wait cycle is referred to as a read to write wait stat e in this document. this wait cycle is applied in add ition to chip select and reload user configuration wait states when they are to be inserted. see figure 28-17 on page 497 .
501 32015a?avr32?02/07 AT32AP7001 28.12 data float wait states some memory devices are slow to release the exte rnal bus. for such devices, it is necessary to add wait states (data float wait states) after a read access: ? before starting a read access to a different external memory ? before starting a write access to the same device or to a different external one. the data float output time (t df ) for each external memory device is programmed in the tdf_cycles field of the mode register for the corresponding chip select. the value of tdf_cycles indicates the number of data float wait cycles (between 0 and 15) before the external device releases the bus, and represents the time allowed for the data output to go to high impedance after the memory is disabled. data float wait states do not delay internal memory accesses. hence, a single access to an external memory with long t df will not slow down the executio n of a program from internal memory. the data float wait states management depends on the read_mode and the tdf_mode fields of the mode register for the corresponding chip select. 28.12.1 read_mode setting the read_mode to 1 indicates to the smc that the nrd signal is responsible for turn- ing off the tri-state buffers of the external memory device. the data float period then begins after the rising edge of the nrd sign al and lasts tdf_cycles mck cycles. when the read operation is controlled by the ncs signal (read_mode = 0), the tdf field gives the number of mck cycles during which the data bus remains busy after the rising edge of ncs. figure 28-21 on page 502 illustrates the data float period in nrd-controlled mode (read_mode =1), assuming a data float period of 2 cycles (tdf_cycles = 2). figure 28-22 on page 502 shows the read operation when controlled by ncs (read_mode = 0) and the tdf_cycles parameter equals 3.
502 32015a?avr32?02/07 AT32AP7001 figure 28-21. tdf period in nrd controlled read access (tdf = 2) figure 28-22. tdf period in ncs controlled read operation (tdf = 3) nbs0, nbs1, nbs2, nbs3, a0, a1 ncs nrd controlled read operation tpacc mck nrd d[31:0] tdf = 2 clock cycles a[25:2] ncs tdf = 3 clock cycles tpacc mck d[31:0] ncs controlled read operation a[25:2] nbs0, nbs1, nbs2, nbs3, a0,a1 nrd
503 32015a?avr32?02/07 AT32AP7001 28.12.2 tdf optimization enabled (tdf_mode = 1) when the tdf_mode of the mode register is set to 1 (tdf optimization is enabled), the smc takes advantage of the setup period of the next access to optimize the number of wait states cycle to insert. figure 28-23 on page 503 shows a read access controlled by nrd, followed by a write access controlled by nwe, on chip select 0. chip select 0 has been programmed with: nrd_hold = 4; read_mode = 1 (nrd controlled) nwe_setup = 3; write_mode = 1 (nwe controlled) tdf_cycles = 6; tdf_mode = 1 (optimization enabled). figure 28-23. tdf optimization: no tdf wait states are inserted if the tdf period is over when the next access begins 28.12.3 tdf optimization disabled (tdf_mode = 0) when optimization is disabled, tdf wait states are inserted at the end of the read transfer, so that the data float period is ended when the second access begins. if the hold period of the read1 controlling signal overlaps the data float period, no additional tdf wait st ates will be inserted. figure 28-24 on page 504 , figure 28-25 on page 504 and figure 28-26 on page 505 illustrate the cases: ? read access followed by a read access on another chip select, ? read access followed by a write access on another chip select, ? read access followed by a write access on the same chip select, with no tdf optimization. a [25:2] ncs0 mck nrd nwe d[31:0] read to write wait state tdf_cycles = 6 read access on ncs0 (nrd controlled) nrd_hold= 4 nwe_setup= 3 write access on ncs0 (nwe controlled)
504 32015a?avr32?02/07 AT32AP7001 figure 28-24. tdf optimization disabled (tdf mode = 0). tdf wait states between 2 read accesses on different chip selects figure 28-25. tdf mode = 0: tdf wait states between a read and a write access on different chip selects tdf_cycles = 6 tdf_cycles = 6 tdf_mode = 0 (optimization disabled) a[ 25:2] read1 cycle chip select wait state mck read1 controlling signal (nrd) read2 controlling signal (nrd) d[31:0] read1 hold = 1 read 2 cycle read2 setup = 1 5 tdf wait states nbs0, nbs1, nbs2, nbs3, a0, a1 tdf_cycles = 4 tdf_cycles = 4 tdf_mode = 0 (optimization disabled) a [25:2] read1 cycle chip select wait state read to write wait state mck read1 controlling signal (nrd) write2 controlling signal (nwe) d[31:0] read1 hold = 1 write2 cycle write2 setup = 1 2 tdf wait states nbs0, nbs1, nbs2, nbs3, a0, a1
505 32015a?avr32?02/07 AT32AP7001 figure 28-26. tdf mode = 0: tdf wait states between read and write accesses on the same chip select 28.13 external wait any access can be extended by an external device using the nw ait input signal of the smc. the exnw_mode field of the mode register on the corresponding chip select must be set to either to ?10? (frozen mode) or ?11? (ready mode). when the exnw_mode is set to ?00? (dis- abled), the nwait signal is simply ignored on the corresponding chip select. the nwait signal delays the read or write operation in regards to the read or wr ite controlling signal, depending on the read and write modes of the corresponding chip select. 28.13.1 restriction when one of the exnw_mode is enabled, i t is mandatory to program at least one hold cycle for the read/write controlling signal. for that reason, the nwait signal cannot be used in page mode ( ?asynchronous page mode? on page 514 ), or in slow clock mode ( ?slow clock mode? on page 511 ). the nwait signal is assumed to be a response of the external device to the read/write request of the smc. then nwait is examined by the smc only in the pulse state of the read or write controlling signal. the assertion of the nwait signal outside th e expected period has no impact on smc behavior. tdf_cycles = 5 tdf_cycles = 5 tdf_mode = 0 (optimization disabled) a [25:2] read1 cycle read to write wait state mck read1 controlling signal (nrd) write2 controlling signal (nwe) d[31:0] read1 hold = 1 write2 cycle write2 setup = 1 4 tdf wait states nbs0, nbs1, nbs2, nbs3, a0, a1
506 32015a?avr32?02/07 AT32AP7001 28.13.2 frozen mode when the external device asserts the nwait signal (active low), and after internal synchroniza- tion of this signal, the smc state is frozen, i.e., smc internal counters are frozen, and all control signals remain unchanged. when the resynchronized nwait signal is deasserted, the smc completes the access, resuming the access from the point where it was stopped. see figure 28- 27 on page 506 . this mode must be selected when the ex ternal device uses the nwait signal to delay the access and to freeze the smc. the assertion of the nwait sign al outside the expected period is ignored as illustrated in figure 28-28 on page 507 . figure 28-27. write access with nwait assertion in frozen mode (exnw_mode = 10) exnw_mode = 10 (frozen) write_mode = 1 (nwe_controlled) nwe_pulse = 5 ncs_wr_pulse = 7 a [25:2] mck nwe ncs 432 1 110 1 4 5 63222210 write cycle d[31:0] nwait frozen state nbs0, nbs1, nbs2, nbs3, a0,a1 internally synchronized nwait signal
507 32015a?avr32?02/07 AT32AP7001 figure 28-28. read access with nwait assertion in frozen mode (exnw_mode = 10) exnw_mode = 10 (frozen) read_mode = 0 (ncs_controlled) nrd_pulse = 2, nrd_hold = 6 ncs_rd_pulse =5, ncs_rd_hold =3 a [25:2] mck ncs nrd 10 43 43 2 555 22 0 210 210 1 read cycle assertion is ignored nwait internally synchronized nwait signal frozen state nbs0, nbs1, nbs2, nbs3, a0,a1
508 32015a?avr32?02/07 AT32AP7001 28.13.3 ready mode in ready mode (exnw_mode = 11), the smc behaves differently. normally, the smc begins the access by down counting the setup and pulse counters of the read/write controlling signal. in the last cycle of the pulse phase, the resynchronized nwait signal is examined. if asserted, the smc suspends the access as shown in figure 28-29 on page 508 and figure 28-30 on page 509 . after deassertion, the access is completed: the hold step of the access is performed. this mode must be selected when the external de vice uses deassertion of the nwait signal to indicate its ability to complete the read or write operation. if the nwait signal is deasserted before the end of the pulse, or asserted after the end of the pulse of the controlling read/write signal, it has no impact on the access length as shown in fig- ure 28-30 on page 509 . figure 28-29. nwait assertion in write access: ready mode (exnw_mode = 11) exnw_mode = 11 (ready mode) write_mode = 1 (nwe_controlled) nwe_pulse = 5 ncs_wr_pulse = 7 a [25:2] mck nwe ncs 432 1 00 0 4 5 6321110 write cycle d[31:0] nwait internally synchronized nwait signal wait state nbs0, nbs1, nbs2, nbs3, a0,a1
509 32015a?avr32?02/07 AT32AP7001 figure 28-30. nwait assertion in read access: ready mode (exnw_mode = 11) exnw_mode = 11(ready mode) read_mode = 0 (ncs_controlled) nrd_pulse = 7 ncs_rd_pulse =7 a[25:2] mck ncs nrd 4 5 63200 0 1 4 5 6321 1 read cycle assertion is ignored nwait internally synchronized nwait signal wait state assertion is ignored nbs0, nbs1, nbs2, nbs3, a0,a1
510 32015a?avr32?02/07 AT32AP7001 28.13.4 nwait latency and read/write timings there may be a latency between the assertion of the read/w rite controlling signal and the asser- tion of the nwait signal by the device. t he programmed pulse length of the read/write controlling signal must be at least equal to this latency plus the 2 cycles of resynchronization + 1 cycle. otherwise, the smc may enter the hold state of the access without detecting the nwait signal assertion. this is true in frozen mode as well as in ready mode. this is illustrated on fig- ure 28-31 on page 510 . when exnw_mode is enabled (ready or frozen), th e user must program a pulse length of the read and write controllin g signal of at least: minimal pulse length = nwait latency + 2 resynchronization cycles + 1 cycle figure 28-31. nwait latency exnw_mode = 10 or 11 read_mode = 1 (nrd_controlled) nrd_pulse = 5 a [25:2] mck nrd 43 210 0 0 read cycle minimal pulse length nwait latency nwait intenally synchronized nwait signal wait state 2 cycle resynchronization nbs0, nbs1, nbs2, nbs3, a0,a1
511 32015a?avr32?02/07 AT32AP7001 28.14 slow clock mode the smc is able to automatically apply a set of ?slow clock mode? read/write waveforms when an internal signal driven by the power management controller is asserted because mck has been turned to a slow clock rate (typically 32 khz clock rate). in this mode, the user-programmed waveforms are ignored and the slow clock mode waveforms are applied. this mode is provided so as to avoid reprogramming the user interfac e with appropriate waveforms at very slow clock rate. when activated, the slow mode is active on all chip selects. 28.14.1 slow clock mode waveforms figure 28-32 on page 511 illustrates the read and write operations in slow clock mode. they are valid on all chip selects. section 28-6 on page 511 indicates the value of read and write parame- ters in slow clock mode. figure 28-32. read/write cycles in slow clock mode a[ 25:2] ncs 1 mck nwe 1 1 nwe_cycle = 3 a [25:2] mck nrd nrd_cycle = 2 1 1 ncs slow clock mode write slow clock mode read nbs0, nbs1, nbs2, nbs3, a0,a1 nbs0, nbs1, nbs2, nbs3, a0,a1 table 28-6. read and write timing parameters in slow clock mode read parameters duration (cycles) write parameters duration (cycles) nrd_setup 1 nwe_setup 1 nrd_pulse 1 nwe_pulse 1 ncs_rd_setup 0 ncs_wr_setup 0 ncs_rd_pulse 2 ncs_wr_pulse 3 nrd_cycle 2 nwe_cycle 3
512 32015a?avr32?02/07 AT32AP7001 28.14.2 switching from (to) slow clock mode to (from) normal mode when switching from slow clock mode to the nor mal mode, the current slow clock mode transfer is completed at high clock rate, with the set of slow clock mode parameters.see figure 28-33 on page 512 . the external device may not be fast enough to support such timings. figure 28-34 on page 513 illustrates the recommended procedur e to properly switch from one mode to the other. figure 28-33. clock rate transition occurs while the smc is performing a write operation a [25:2] ncs 1 mck nwe 1 1 nwe_cycle = 3 slow clock mode write slow clock mode internal signal from pmc 11 1 2 3 2 nwe_cycle = 7 normal mode write slow clock mode transition is detected: reload configuration wait state this write cycle finishes with the slow clock mode set of parameters after the clock rate transition slow clock mode write nbs0, nbs1, nbs2, nbs3, a0,a1
513 32015a?avr32?02/07 AT32AP7001 figure 28-34. recommended procedure to switch from slow clock mo de to normal mode or from normal mode to slow clock mode a [25:2] ncs 1 mck nwe 1 1 slow clock mode write slow clock mode internal signal from pmc 2 3 2 normal mode write idle state reload configuration wait state nbs0, nbs1, nbs2, nbs3, a0,a1
514 32015a?avr32?02/07 AT32AP7001 28.15 asynchronous page mode the smc supports asynchronous burst reads in page mode, providing that the page mode is enabled in the mode register (pmen field). t he page size must be configured in the mode register (ps field) to 4, 8, 16 or 32 bytes. the page defines a set of consecutive bytes into memory. a 4-byte page (resp. 8-, 16-, 32-byte page) is always aligned to 4-byte boundaries (resp. 8-, 16-, 32-byte boundaries) of memory. the msb of data address defines the address of the page in memory, the lsb of address define the address of the data in the page as detailed in table 28-7 on page 514 . with page mode memory devices, the first access to one page (t pa ) takes longer than the subse- quent accesses to the page (t sa ) as shown in figure 28-35 on page 514 . when in page mode, the smc enables the user to define different r ead timings for the first access within one page, and next accesses within the page. notes: 1. a denotes the address bus of the memory device 2. for 16-bit devices, the bit 0 of address is igno red. for 32-bit devices, bits [1:0] are ignored. 28.15.1 protocol and timings in page mode figure 28-35 on page 514 shows the nrd and ncs timings in page mode access. figure 28-35. page mode read protocol (address msb and lsb are defined in table 28-7 on page 514 ) the nrd and ncs signals are held low during all read transfers, whatever the programmed val- ues of the setup and hold timings in the us er interface may be. moreover, the nrd and ncs timings are identical. the pulse length of the first access to the page is defined with the table 28-7. page address and data address within a page page size page address (1) data address in the page (2) 4 bytes a[25:2] a[1:0] 8 bytes a[25:3] a[2:0] 16 bytes a[25:4] a[3:0] 32 bytes a[25:5] a[4:0] a[msb] ncs mck nrd d[31:0] ncs_rd_pulse nrd_pulse nrd_pulse tsa tpa tsa a[lsb]
515 32015a?avr32?02/07 AT32AP7001 ncs_rd_pulse field of the pulse register. the pulse length of subsequent accesses within the page are defined usin g the nrd_pulse parameter. in page mode, the programming of the read timings is described in table 28-8 on page 515 : the smc does not check the coherency of timings. it will always apply the ncs_rd_pulse timings as page access timing (t pa ) and the nrd_pulse for accesses to the page (t sa ), even if the programmed value for t pa is shorter than the programmed value for t sa . 28.15.2 byte access type in page mode the byte access type configuration remains active in page mode. for 16-bit or 32-bit page mode devices that require byte selection signals, configure the bat field of the smc_register to 0 (byt e select access type). 28.15.3 page mode restriction the page mode is not compatible with the use of the nwait signal. using the page mode and the nwait signal may lead to unpredictable behavior. 28.15.4 sequential and non-sequential accesses if the chip select and the msb of addresses as defined in table 28-7 on page 514 are identical, then the current access lies in the same page as the previous one, and no page break occurs. using this information, all data within the same page, sequential or not sequential, are accessed with a minimum access time (t sa ). figure 28-36 on page 516 illustrates access to an 8-bit mem- ory device in page mode, with 8-byte pages. access to d1 causes a page access with a long access time (t pa ). accesses to d3 and d7, though they are not sequential accesses, only require a short access time (t sa ). if the msb of addresses are different, the smc performs the access of a new page. in the same way, if the chip select is diffe rent from the previous access, a page break occurs. if two sequen- tial accesses are made to the page mode memory , but separated by an other internal or external peripheral access, a page break occurs on the second access because the chip select of the device was deasserted between both accesses. table 28-8. programming of read timings in page mode parameter value definition read_mode ?x? no impact ncs_rd_setup ?x? no impact ncs_rd_pulse t pa access time of first access to the page nrd_setup ?x? no impact nrd_pulse t sa access time of subsequent accesses in the page nrd_cycle ?x? no impact
516 32015a?avr32?02/07 AT32AP7001 figure 28-36. access to non-sequential data within the same page a [25:3] 2 ], a1, a0 ncs mck nrd page address a1 a3 a7 d[7:0] ncs_rd_pulse nrd_pulse nrd_pulse d1 d3 d7
517 32015a?avr32?02/07 AT32AP7001 28.16 static memory contro ller (smc) user interface the smc is programmed using the registers listed in table 28-9 on page 517 . for each chip select, a set of 4 registers is used to program the parameters of th e external device connected on it. in table 28-9 on page 517 , ?cs_number? denotes the chip select number. 16 bytes (0x1 0) are required per chip select. the user must complete writing the configuration by writing any one of the mode registers. table 28-9. smc register mapping offset register name access reset state 0x10 x cs_number + 0x00 smc setup register setup read/write 0x00010001 0x10 x cs_number + 0x04 smc pulse register pulse read/write 0x04030402 0x10 x cs_number + 0x08 smc cycle register cycle read/write 0x00050005 0x10 x cs_number + 0x0c smc mode register mode read/write 0x10002103
518 32015a?avr32?02/07 AT32AP7001 28.16.1 smc setup register register name: setup[0 .. nb_cs-1 ] access type: read/write ? nwe_setup: nwe setup length the nwe signal setup length is defined as: nwe setup length = (128* nwe_setup [5] + nwe_setup[4:0]) clock cycles ? ncs_wr_setup: ncs setup length in write access in write access, the ncs signal setup length is defined as: ncs setup length = (128* ncs_wr_setup [5] + ncs_wr_setup[4:0]) clock cycles ? nrd_setup: nrd setup length the nrd signal setup length is defined in clock cycles as: nrd setup length = (128* nrd_setup[5] + nrd_setup[4:0]) clock cycles ? ncs_rd_setup: ncs setup length in read access in read access, the ncs signal setup length is defined as: ncs setup length = (128* ncs_rd_setup [5] + ncs_rd_setup[4:0]) clock cycles 31 30 29 28 27 26 25 24 ? ? ncs_rd_setup 23 22 21 20 19 18 17 16 ? ? nrd_setup 15 14 13 12 11 10 9 8 ? ? ncs_wr_setup 76543210 ? ? nwe_setup
519 32015a?avr32?02/07 AT32AP7001 28.16.2 smc pulse register register name: pulse[0.. nb_cs-1 ] access type: read/write ? nwe_pulse: nwe pulse length the nwe signal pulse length is defined as: nwe pulse length = (256* nwe_pulse[6] + nwe_pulse[5:0]) clock cycles the nwe pulse length must be at least 1 clock cycle. ? ncs_wr_pulse: ncs pulse length in write access in write access, the ncs signal pulse length is defined as: ncs pulse length = (256* ncs_wr_pul se[6] + ncs_wr_pulse[5:0]) clock cycles the ncs pulse length must be at least 1 clock cycle. ? nrd_pulse: nrd pulse length in standard read access, the nrd signal pulse length is defined in clock cycles as: nrd pulse length = (256* nrd_pulse[ 6] + nrd_pulse[5:0]) clock cycles the nrd pulse length must be at least 1 clock cycle. in page mode read access, the nrd_pulse parameter defines the duration of the subsequent accesses in the page. ? ncs_rd_pulse: ncs pulse length in read access in standard read access, the ncs signal pulse length is defined as: ncs pulse length = (256* ncs_rd_pul se[6] + ncs_rd_pulse[5:0]) clock cycles the ncs pulse length must be at least 1 clock cycle. in page mode read access, the ncs_rd_pulse parameter defines the duration of the first access to one page. 31 30 29 28 27 26 25 24 ? ncs_rd_pulse 23 22 21 20 19 18 17 16 ? nrd_pulse 15 14 13 12 11 10 9 8 ? ncs_wr_pulse 76543210 ?nwe_pulse
520 32015a?avr32?02/07 AT32AP7001 28.16.3 smc cycle register register name: cycle[0.. nb_cs-1 ] access type: read/write ? nwe_cycle: total write cycle length the total write cycle length is the total du ration in clock cycles of the write cycle. it is equal to the sum of the setup, pul se and hold steps of the nwe and ncs signals. it is defined as: write cycle length = (nwe_cycle[8:7 ]*256 + nwe_cycle[6:0]) clock cycles ? nrd_cycle: total read cycle length the total read cycle length is the total duration in clock cycles of the read cycle. it is equal to the sum of the setup, pulse and hold steps of the nrd and ncs signals. it is defined as: read cycle length = (nrd_cycle[8:7] *256 + nrd_cycle[6:0]) clock cycles 31 30 29 28 27 26 25 24 ???????nrd_cycle 23 22 21 20 19 18 17 16 nrd_cycle 15 14 13 12 11 10 9 8 ???????nwe_cycle 76543210 nwe_cycle
521 32015a?avr32?02/07 AT32AP7001 28.16.4 smc mode register register name: mode[0.. nb_cs-1 ] access type: read/write ? read_mode: 1: the read operation is controlled by the nrd signal. ? if tdf cycles are programmed, the external bus is marked busy after the rising edge of nrd. ? if tdf optimization is enabled (tdf_mode =1), tdf wait states are inserted after the setup of nrd. 0: the read operation is controlled by the ncs signal. ? if tdf cycles are programmed, the external bus is marked busy after the rising edge of ncs. ? if tdf optimization is enabled (tdf_mode =1), tdf wait states are inserted after the setup of ncs. ?write_mode 1: the write operation is controlled by the nwe signal. ? if tdf optimization is enabled (tdf_mode =1), tdf wa it states will be inserted after the setup of nwe. 0: the write operation is controlled by the ncs signal. ? if tdf optimization is enabled (tdf_mode =1), tdf wa it states will be inserted after the setup of ncs. ? exnw_mode: nwait mode the nwait signal is used to extend the current read or writ e signal. it is only taken into account during the pulse phase of the read and writ e controlling signal. when the use of nwait is enable d, at least one cycle hold duration mu st be pro- grammed for the read and write controlling signal. ? disabled mode: the nwait input signal is ignored on the corresponding chip select. ? frozen mode: if asserted, the nwait signal freezes the current read or write cycle. after deassertion, the read/write cycle is resumed from the point where it was stopped. 31 30 29 28 27 26 25 24 ?? ps ???pmen 23 22 21 20 19 18 17 16 ? ? ? tdf_mode tdf_cycles 15 14 13 12 11 10 9 8 ?? dbw ???bat 76543210 ?? exnw_mode ?? write_mod e read_mode exnw_mode nwait mode 00disabled 01reserved 1 0 frozen mode 1 1 ready mode
522 32015a?avr32?02/07 AT32AP7001 ? ready mode: the nwait si gnal indicates the availa bility of the external device at t he end of the pulse of the controlling read or write signal, to complete the access. if high, the access normally completes. if low, the access is extended until nwait returns high. ? bat: byte access type this field is used only if dbw defines a 16- or 32-bit data bus. ? 1: byte write access type: ? write operation is controlled us ing ncs, nwr0, nwr1, nwr2, nwr3. ? read operation is controlled using ncs and nrd. ? 0: byte select access type: ? write operation is controlled using ncs, nwe, nbs0, nbs1, nbs2 and nbs3 ? read operation is controlled using ncs, nrd, nbs0, nbs1, nbs2 and nbs3 ? dbw: data bus width ? tdf_cycles: data float time this field gives the integer number of clock cycles required by the external device to release the data after the rising edge of the read controlling signal. the smc always provide one full cycle of bus turnaround after the tdf_cycles period. the external bus cannot be used by another chip select during tdf_cycles + 1 cycles. from 0 up to 15 tdf_cycles can be set. ? tdf_mode: tdf optimization 1: tdf optimization is enabled. ? the number of tdf wait states is optimized using the setup period of the next read/write access. 0: tdf optimization is disabled. ? the number of tdf wait states is inserted before the next access begins. ? pmen: page mode enabled 1: asynchronous burst read in page mode is applied on the corresponding chip select. 0: standard read is applied. ? ps: page size if page mode is enabled, this field indicates the size of the page in bytes. dbw data bus width 008-bit bus 0116-bit bus 1032-bit bus 11reserved ps page size 0 0 4-byte page 0 1 8-byte page 1 0 16-byte page 1 1 32-byte page
523 32015a-avr32-02/07 AT32AP7001 29. sdram controller (sdramc) rev: 2.0.0.0 29.1 features ? numerous configurations supported ? 2k, 4k, 8k row address memory parts ? sdram with two or four internal banks ? sdram with 16- or 32-bit data path ? programming facilities ? word, half-word, byte access ? automatic page break when memory boundary has been reached ? multibank ping-pong access ? timing parameters specified by software ? automatic refresh operation, refresh rate is programmable ? automatic update of ds, tcr and pa sr parameters (mobi le sdram devices) ? energy-saving capabilities ? self-refresh, power-down and deep power modes supported ? supports mobile sdram devices ? error detection ? refresh error interrupt ? sdram power-up initialization by software ? cas latency of 1, 2, 3 supported ? auto precharge command not used 29.2 description the sdram controller (sdramc) extends the memory capabilities of a chip by providing the interface to an external 16-bit or 32-bit sdram device. the page size supports ranges from 2048 to 8192 and the number of columns from 256 to 2048. it supports byte (8-bit), half-word (16-bit) and word (32-bit) accesses. the sdram controller supports a read or write burst length of one location. it keeps track of the active row in each bank, thus maximizing sd ram performance, e.g., the application may be placed in one bank and data in the other banks. so as to optimize performance, it is advisable to avoid accessing different rows in the same bank. the sdram controller supports a cas latency of 1, 2 or 3 and optimizes the read access depending on the frequency. the different modes available - self-refresh, power-down and deep power-down modes - mini- mize power consumption on the sdram device.
524 32015a-avr32-02/07 AT32AP7001 29.3 block diagram figure 29-1. sdram controller block diagram 29.4 i/o lines description memory controller peripheral bus sdramc interrupt sdck sdcs sdramc_a[12:0] sdramc pio controller ba[1:0] sdcke ras cas sdwe nbs[3:0] user interface pmc mck d[31:0] sdramc chip select table 29-1. i/o line description name description type active level sdck sdram clock output sdcke sdram clock enable output high sdcs sdram controller chip select output low ba[1:0] bank sele ct signals output ras row signal output low cas column signal output low sdwe sdram write enable output low nbs[3:0] data mask enable signals output low sdramc_a[12:0] address bus output d[31:0] data bus i/o
525 32015a-avr32-02/07 AT32AP7001 29.5 application example 29.5.1 hardware interface figure 29-2 shows an example of sdram device connec tion to the sdram controller using a 32-bit data bus width. figure 29-3 shows an example of sdram device connection using a 16- bit data bus width. it is important to note that th ese examples are given for a direct connection of the devices to the sdram controller, without external bus interface or pio controller multiplexing. figure 29-2. sdram controller connections to sdra m devices: 32-bit data bus width figure 29-3. sdram controller connections to sdra m devices: 16-bit data bus width sdram controller d0-d31 sdramc_a[0-12] ras cas sdck sdcke sdwe nbs0 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 nbs1 nbs2 nbs3 sdcs d0-d7 d8-d15 ba0 ba1 a10 sdramc_a10 sdramc_a[0-9], sdramc_a11 ba0 ba1 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 a10 sdramc_a10 sdramc_a[0-9], sdramc_a11 ba0 ba1 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 d16-d23 d24-d31 a10 sdramc_a10 sdramc_a[0-9], sdramc_ a11 ba0 ba1 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 a10 sdramc_a10 sdramc_a[0-9], sdramc_a11 ba0 ba1 nbs0 nbs1 nbs3 nbs2 sdwe sdwe sdwe sdwe sdram controller d0-d31 sdramc_a[0-12] ras cas sdck sdcke sdwe nbs0 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 nbs1 sdcs d0-d7 d8-d15 ba0 ba1 a10 sdramc_a10 sdramc_a[0-9], sdramc_a11 ba0 ba1 2m x 8 sdram d0-d7 a0-a9, a11 ras cas clk cke we dqm cs ba0 ba1 a10 sdramc_a10 sdramc_a[0-9], sdramc_a11 ba0 ba1 nbs0 nbs1 sdwe sdwe
526 32015a-avr32-02/07 AT32AP7001 29.5.2 software interface the sdram address space is organized into banks, rows, and columns. the sdram controller allows mapping different memory types according to the values set in the sdramc configura- tion register. the sdram controller?s function is to make the sdram device access protocol transparent to the user. table 29-2 to table 29-7 illustrate the sdram device memory mapping seen by the user in correlation with the device structure. various co nfigurations are illustrated. 29.5.2.1 32-bit memory data bus width notes: 1. m[1:0] is the byte address inside a 32-bit word. 2. bk[1] = ba1, bk[0] = ba0. table 29-2. sdram configuration mapping: 2k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 09876543210 bk[1:0] row[10:0] column[7:0] m[1:0] bk[1:0] row[10:0] column[8:0] m[1:0] bk[1:0] row[10:0] column[9:0] m[1:0] bk[1:0] row[10:0] column[10:0] m[1:0] table 29-3. sdram configuration mapping: 4k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 09876543210 bk[1:0] row[11:0] column[7:0] m[1:0] bk[1:0] row[11:0] column[8:0] m[1:0] bk[1:0] row[11:0] column[9:0] m[1:0] bk[1:0] row[11:0] column[10:0] m[1:0] table 29-4. sdram configuration mapping: 8k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 09876543210 bk[1:0] row[12:0] column[7:0] m[1:0] bk[1:0] row[12:0] column[8:0] m[1:0] bk[1:0] row[12:0] column[9:0] m[1:0] bk[1:0] row[12:0] column[10:0] m[1:0]
527 32015a-avr32-02/07 AT32AP7001 29.5.2.2 16-bit memory data bus width notes: 1. m0 is the byte address inside a 16-bit half-word. 2. bk[1] = ba1, bk[0] = ba0. table 29-5. sdram configuration mapping: 2k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 09876543210 bk[1:0] row[10:0] column[7:0] m 0 bk[1:0] row[10:0] column[8:0] m 0 bk[1:0] row[10:0] column[9:0] m 0 bk[1:0] row[10:0] column[10:0] m 0 table 29-6. sdram configuration mapping: 4k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 09876543210 bk[1:0] row[11:0] column[7:0] m 0 bk[1:0] row[11:0] column[8:0] m 0 bk[1:0] row[11:0] column[9:0] m 0 bk[1:0] row[11:0] column[10:0] m 0 table 29-7. sdram configuration mapping: 8k rows, 256/512/1024/2048 columns cpu address line 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 9 1 8 1 7 1 6 1 5 1 4 1 3 1 2 1 1 1 09876543210 bk[1:0] row[12:0] column[7:0] m 0 bk[1:0] row[12:0] column[8:0] m 0 bk[1:0] row[12:0] column[9:0] m 0 bk[1:0] row[12:0] column[10:0] m 0
528 32015a-avr32-02/07 AT32AP7001 29.6 product dependencies 29.6.1 sdram device initialization the initialization sequence is generated by softw are. the sdram devices are initialized by the following sequence: 1. sdram features must be set in the configuration register: asynchronous timings (trc, tras, ...), number of column, rows, cas latency, and the data bus width. 2. for mobile sdram, temperature-compensated self refresh (tcsr), drive strength (ds) and partial array self refresh (pasr) must be set in the low power register. 3. the sdram memory type must be set in the memory device register. 4. a minimum pause of 200 s is provided to precede any signal toggle. 5. an all banks precharge command must be issued to the sdram devices. the applica- tion must set mode to 2 in the mode register and perform a write access to any sdram address. 6. eight auto-refresh (cbr) cycles are provided. the application must set the mode to 4 in the mode register and performs a write access to any sdram location eight times. 7. a mode register set (mrs) cycle must be issued to program the parameters of the sdram devices, in particular cas latency and burst length. the application must set mode to 3 in the mode register and perform a write access to the sdram. the write address must be chosen so that ba[1:0] are set to 0. for example, with a 16-bit 128 mb sdram (12 rows, 9 columns, 4 banks) bank address, the sdram write access should be done at the address 0x20000000. 8. for mobile sdram initialization, an extended mode register set (emrs) cycle must be issued to program the sdram parameters (t csr, pasr, ds). the application must set mode to 5 in the mode register and perform a write access to the sdram. the write address must be chosen so that ba[1] or ba[0] are set to 1. for example, with a 16-bit 128 mb sdram, (12 rows, 9 columns, 4 banks) bank address the sdram write access should be done at the address 0x20800000 or 0x20400000. 9. the application must go into normal mode, setting mode to 0 in the mode register and performing a write access at any location in the sdram. 10. write the refresh rate into the count field in the sdramc refresh timer register. (refresh rate = delay between refresh cycles). the sdram device requires a refresh every 15.625 us or 7.81 us. with a 100 mh z frequency, the refresh timer counter reg- ister must be set with the value 1562 (15.625 s x 100 mhz) or 781 (7.81 s x 100 mhz). after initialization, the sdram devices are fully functional.
529 32015a-avr32-02/07 AT32AP7001 figure 29-4. sdram device initialization sequence 29.6.2 i/o lines the pins used for interfacing the sdram contro ller may be multiplexed with the pio lines. the programmer must first program the pio controller to assign the sdram controller pins to their peripheral function. if i/o lines of the sdram controller are not used by the application, they can be used for other purposes by the pio controller. 29.6.3 interrupt the sdram controller has an interrupt line connected to the interrupt controller. in order to han- dle interrupts, the interrupt controller must be programmed before configuring the sdram controller. using the sdram controller interrupt requires the ic to be programmed first.) sdck sdramc_a[9:0] a10 sdramc_a[12:11] sdcs ras cas sdwe nbs inputs stable for 200 sec precharge all banks 1st auto-refresh 8th auto-refresh mrs command valid command sdcke t rp t rc t mrd
530 32015a-avr32-02/07 AT32AP7001 29.7 functional description 29.7.1 sdram controller write cycle the sdram controller allows burst access or single access. in both cases, the sdram control- ler keeps track of the active row in each bank, th us maximizing performance. to initiate a burst access, the sdram controller uses the transfe r type signal provided by the master requesting the access. if the next access is a sequential write access, writing to the sdram device is car- ried out. if the next access is a write-sequential access, but the current a ccess is to a boundary page, or if the next access is in another ro w, then the sdram controller generates a precharge command, activates the new row and initiates a write command. to comply with sdram timing parameters, additional clock cycles ar e inserted between precharge/active (t rp ) commands and active/write (t rcd ) commands. for definition of these timing parameters, refer to the ?sdramc configuration register? on page 540 . this is described in figure 29-5 below. figure 29-5. write burst, 32-bit sdram access 29.7.2 sdram controller read cycle the sdram controller allows burst access, incremental burst of unspecified length or single access. in all cases, the sdram controller keeps track of the active row in each bank, thus maximizing performance of the sdram. if row and bank addresses do not match the previous row/bank address, then the sdram controller automatically generates a precharge command, activates the new row and starts the read command. to comply with the sdram timing param- eters, additional clock cycles on sdck are inserted between precharge and active commands (t rp ) and between active and read command (t rcd ). these two parameters are set in the config- uration register of the sdram controller. after a read command, additional wait states are generated to comply with the cas latency (1, 2 or 3 clock delays specified in the configuration register). sdck sdcs ras cas sdramc_a[12:0] d[31:0] t rcd = 3 dna sdwe dnb dnc dnd dne dnf dng dnh dni dnj dnk dnl row n col a col b col c col d col e col f col g col h col i col j col k col l
531 32015a-avr32-02/07 AT32AP7001 for a single access or an incremented burst of unspecified length, the sdram controller antici- pates the next access. while the last value of t he column is returned by the sdram controller on the bus, the sdram controller anticipates the read to the next column and thus anticipates the cas latency. this reduces the effect of the cas latency on the internal bus. for burst access of specified length (4, 8, 16 words), access is not anticipated. this case leads to the best performance. if the burst is broken (border, busy mode, etc.), the next access is han- dled as an incrementing burst of unspecified length. figure 29-6. read burst, 32-bit sdram access 29.7.3 border management when the memory row boundary has been reached, an automatic page break is inserted. in this case, the sdram controller generates a precharge command, activates the new row and ini- tiates a read or write command. to comply with sdram timing parameters, an additional clock cycle is inserted between the precharge/active (t rp ) command and the active/read (t rcd ) com- mand. this is described in figure 29-7 below. sdck sdcs ras cas sdramc_a[12:0] d[31:0] (input) t rcd = 3 dna sdwe dnb dnc dnd dne dnf row n col a col b col c col d col e col f cas = 2
532 32015a-avr32-02/07 AT32AP7001 figure 29-7. read burst with boundary row access 29.7.4 sdram controller refresh cycles an auto-refresh command is used to refresh the sdram device. refresh addresses are gener- ated internally by the sdram device and incremented after each auto-refresh automatically. the sdram controller generates these auto-refresh commands periodically. an internal timer is loaded with the value in the register tr that indicates the number of clock cycles between refresh cycles. a refresh error interrupt is generated when the previous auto-refresh command did not perform. it is acknowledged by reading the interrupt status register (isr). when the sdram controller initia tes a refresh of the sdram devi ce, internal memory accesses are not delayed. however, if the cpu tries to ac cess the sdram, the slave indicates that the device is busy and the master is held by a wait signal. see figure 29-8 . sdck sdcs ras cas sdramc_a[12:0] d[31:0] t rp = 3 sdwe row m col a col a col b col c col d col e dna dnb dnc dnd t rcd = 3 cas = 2 col b col c col d dma dmb dmc dmd row n dme
533 32015a-avr32-02/07 AT32AP7001 figure 29-8. refresh cycle followed by a read access 29.7.5 power management three low-power modes are available: ? self-refresh mode: the sdram executes its own auto-refresh cycle without control of the sdram controller. current drained by the sdram is very low. ? power-down mode: auto-refresh cycles are controlled by the sdram controller. between auto-refresh cycles, the sdram is in power-down. current drained in power-down mode is higher than in self-refresh mode. ? deep power-down mode: (only available with mobile sdram) the sdram contents are lost, but the sdram does not drain any current. the sdram controller activates one low-power mode as soon as the sdram device is not selected. it is possible to delay the entry in self-refresh and power-down mode after the last access by programming a timeout value in the low power register. 29.7.5.1 self-refresh mode this mode is selected by programming the lpcb field to 1 in the sdramc low power register. in self-refresh mode, the sdram device retains data without external clocking and provides its own internal clocking, thus performing its own auto-refresh cycles. all the inputs to the sdram device become ?don?t care? except sdcke, whic h remains low. as soon as the sdram device is selected, the sdram controller provides a sequence of commands and exits self-refresh mode. some low-power sdrams (e.g., mobile sdram) can refresh only one quarter or a half quarter or all banks of the sdram array. this feature reduces the self-refresh current. to configure this feature, temperature compensated self refresh (tcsr), partial array self refresh (pasr) and drive strength (ds) parameters must be set in the low power register and transmitted to the low-power sdram du ring initialization. sdck sdcs ras cas sdramc_a[12:0] d[31:0] (input) t rp = 3 sdwe dnb dnc dnd col c col d cas = 2 row m col a t rc = 8 t rcd = 3 dma row n
534 32015a-avr32-02/07 AT32AP7001 after initialization, as soon as pasr/ds/tcsr fields are modifi ed and self-r efresh mode is acti- vated, the extended mo de register is accessed automatic ally and pasr/ds/tcsr bits are updated before entry into self-refresh mode. the sdram device must remain in self-refresh mode for a minimum period of t ras and may remain in self-refresh mode for an indefinite period. this is described in figure 29-9 . figure 29-9. self-refresh mode behavior 29.7.5.2 low-power mode this mode is selected by programming the lpcb field to 2 in the sdramc low power register. power consumption is greater than in self-refresh mode. all the input and output buffers of the sdram device are deactivated except sdcke, which remains low. in contrast to self-refresh mode, the sdram device cannot remain in low-power mode longer than the refresh period (64 ms for a whole device refresh operation). as no auto-refresh operations are performed by the sdram itself, the sdram controller carries out the refresh operation. the exit procedure is faster than in self-refresh mode. this is described in figure 29-10 . sdck sdcs ras cas sdramc_a[12:0] self refresh mode sdwe row t xsr = 3 sdcke write sdramc_srr srcb = 1 access request to the sdram controller
535 32015a-avr32-02/07 AT32AP7001 figure 29-10. low-power mode behavior 29.7.5.3 deep power-down mode this mode is selected by programming the lpcb field to 3 in the sdramc low power register. when this mode is activated, all internal voltage generators inside the sdram are stopped and all data is lost. when this mode is enabled, the application must not access to the sdram until a new initializa- tion sequence is done (see ?sdram device initialization? on page 528 ). this is described in figure 29-11 . sdck sdcs ras cas sdramc_a[12:0] d[31:0] (input) t rcd = 3 dna dnb dnc dnd dne dnf row n col a col b col c col d col e col f cas = 2 sdcke low power mode
536 32015a-avr32-02/07 AT32AP7001 figure 29-11. deep power-down mode behavior sdck sdcs ras cas sdramc_a[12:0] d[31:0] (input) t rp = 3 sdwe dnb dnc dnd col c col d row n cke
537 32015a-avr32-02/07 AT32AP7001 29.8 sdram controller user interface table 29-8. sdram controller memory map offset register name access reset state 0x00 sdramc mode register mr read/write 0x00000000 0x04 sdramc refresh timer register tr read/write 0x00000000 0x08 sdramc configuration register cr read/write 0x852372c0 0x0c sdramc high speed register hsr read/write 0x00 0x10 sdramc low power register lpr read/write 0x0 0x14 sdramc interrupt enab le register ier write-only ? 0x18 sdramc interrupt disable register idr write-only ? 0x1c sdramc interrupt mask register imr read-only 0x0 0x20 sdramc interrupt status register isr read-only 0x0 0x24 sdramc memory device register mdr read 0x0 0x28 - 0xfc reserved ? ? ?
538 32015a-avr32-02/07 AT32AP7001 29.8.1 sdramc mode register register name :mr access type : read/write reset value : 0x00000000 ? mode: sdramc command mode this field defines the command issued by the sdram controller when the sdram device is accessed. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????? mode table 29-9. mode description 0 0 0 normal mode. any access to the sdram is decoded normally. 0 0 1 the sdram controller issues a nop command when t he sdram device is accessed regardless of the cycle. 010 the sdram controller issues an ?all banks precharge? command when the sdram device is accessed regardless of the cycle. 011 the sdram controller issues a ?load mode register ? command when the sdram device is accessed regardless of the cycle. the address offset with respec t to the sdram device base address is used to program the mode register. for instance, when this mode is acti vated, an access to the ?sdram_base + offset? address generates a ?load mode register? command with the valu e ?offset? written to the sdram device mode register. 100 the sdram controller issues an ?auto-refresh? comm and when the sdram device is accessed regardless of the cycle. previously, an ?all banks precharge? command must be issued. 101 the sdram controller issues an extended load mode regi ster command when the sd ram device is accessed regardless of the cycle. the address offset with respec t to the sdram device base address is used to program the mode register. for instance, when this mode is acti vated, an access to the ?sdram_base + offset? address generates an ?extended load mode register? command with the value ?offset? written to the sdram device mode register. 1 1 0 deep power-down mode. enters deep power-down mode.
539 32015a-avr32-02/07 AT32AP7001 29.8.2 sdramc refresh timer register register name :tr access type : read/write reset value : 0x00000000 ? count: sdramc refresh timer count this 12-bit field is loaded into a timer that generates the refr esh pulse. each time the refresh pulse is generated, a refresh burst is initiated. the value to be loaded depends on the sdramc clock frequency (mck: master clock), the refresh rate of the sdram device and the refresh burst length where 15.6 s per row is a typical value for a burst of length one. to refresh the sdram device, this 12-bit field must be written. if this condition is not satisfied, no refresh command is issued and no refresh of the sdram device is carried out. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???? count 76543210 count
540 32015a-avr32-02/07 AT32AP7001 29.8.3 sdramc configuration register register name :cr access type : read/write reset value : 0x852372c0 ? nc: number of column bits reset value is 8 column bits. ? nr: number of row bits reset value is 11 row bits. ? nb: number of banks reset value is two banks. 31 30 29 28 27 26 25 24 txsr tras 23 22 21 20 19 18 17 16 trcd trp 15 14 13 12 11 10 9 8 trc twr 76543210 dbw cas nb nr nc nc column bits 008 019 1010 1111 nr row bits 00 11 01 12 10 13 11 reserved nb number of banks 02 14
541 32015a-avr32-02/07 AT32AP7001 ? cas: cas latency reset value is two cycles. in the sdramc, only a cas latency of one, two and three cycles is managed. ? dbw: data bus width reset value is 16 bits 0: data bus width is 32 bits. 1: data bus width is 16 bits. ? twr: write recovery delay reset value is two cycles. this field defines the write recovery time in numb er of cycles. number of cycles is between 0 and 15. ? trc: row cycle delay reset value is seven cycles. this field defines the delay between a refresh and an activate command in numbe r of cycles. number of cycles is between 0 and 15. ? trp: row precharge delay reset value is three cycles. this field defines the delay between a precharge command and another command in number of cycles. number of cycles is between 0 and 15. ? trcd: row to column delay reset value is two cycles. this field defines the delay between an activate comman d and a read/write command in number of cycles. number of cycles is between 0 and 15. ? tras: active to precharge delay reset value is five cycles. this field defines the delay between an activate command and a precharge command in number of cycles. number of cycles is between 0 and 15. ? txsr: exit self refr esh to active delay reset value is height cycles. this field defines the delay between scke set high and an activate command in numb er of cycles. number of cycles is between 0 and 15. cas cas latency (cycles) 00 reserved 01 1 10 2 11 3
542 32015a-avr32-02/07 AT32AP7001 29.8.4 sdramc high speed register register name :hsr access type : read/write ? da: decode cycle enable a decode cycle can be added on the addresses as soon as a non-sequential access is performed on the hsb bus. the addition of the decode cycle allows the sdramc to gain time to access the sdram memory. 0: decode cycle is disabled. 1: decode cycle is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????da
543 32015a-avr32-02/07 AT32AP7001 29.8.5 sdramc low power register register name :lpr access type : read/write reset value :0x0 ? lpcb: low-power configuration bits ? pasr: partial array self-refresh (only for low-power sdram) pasr parameter is transmitted to the sdram during initialization to specify whether only one quar ter, one half or all banks of the sdram array are enabled. disabled banks are not refreshed in self-refresh mode. this parameter must be set according to the sdram device specification. after initialization, as soon as pasr fiel d is modified and self-refresh mode is activated, the extended mode register is accessed automatically and pasr bits are updated before entry in self-refresh mode. ? tcsr: temperature compensated self-r efresh (only for low-power sdram) tcsr parameter is transmitted to the sdram during initiali zation to set the refresh interval during self-refresh mode depending on the temperature of the low-power sdram. this parameter must be set according to the sdram device specification. after initialization, as soon as tcsr fi eld is modified and self-refresh mode is activated, the extended mode register is accessed automatically and tcsr bits are updated before entry in self-refresh mode. ? ds: drive strength (only for low-power sdram) ds parameter is transmitted to the sdram during initialization to sele ct the sdram strength of data output. this parame- ter must be set according to the sdram device specification. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?? timeout ds tcsr 76543210 ? pasr ? ? lpcb 00 low power feature is inhibited: no power-down, self -refresh or deep power-down command is issued to the sdram device. 01 the sdram controller issues a self-refresh comm and to the sdram device, the sdclk clock is deactivated and the sdcke signal is set low. t he sdram device leaves the self refresh mode when accessed and enters it after the access. 10 the sdram controller issues a power-down command to the sdram device after each access, the sdcke signal is set to low. the sdram device leaves the power-down mode when accessed and enters it after the access. 11 the sdram controller issues a deep power-down command to the sdram device. this mode is unique to low-power sdram.
544 32015a-avr32-02/07 AT32AP7001 after initialization, as soon as ds fi eld is modified and self-refresh mode is activated, the extended mode register is accessed automatically and ds bits are updated before entry in self-refresh mode. ? timeout: time to define when low-power mode is enabled 00 the sdram controller activates the sdram low-power mo de immediately after the end of the last transfer. 01 the sdram controller activates the sdram low-powe r mode 64 clock cycles afte r the end of the last transfer. 10 the sdram controller activates the sdram low-power mode 128 clock cycles after the end of the last transfer. 11 reserved.
545 32015a-avr32-02/07 AT32AP7001 29.8.6 sdramc interrupt enable register register name :ier access type :write-only ? res: refresh error status 0: no effect. 1: enables the refresh error interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????res
546 32015a-avr32-02/07 AT32AP7001 29.8.7 sdramc interrupt disable register register name :idr access type :write-only ? res: refresh error status 0: no effect. 1: disables the refresh error interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????res
547 32015a-avr32-02/07 AT32AP7001 29.8.8 sdramc interrupt mask register register name :imr access type : read-only ? res: refresh error status 0: the refresh error interrupt is disabled. 1: the refresh error interrupt is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????res
548 32015a-avr32-02/07 AT32AP7001 29.8.9 sdramc interrupt status register register name :isr access type : read-only ? res: refresh error status 0: no refresh error has been detected since the register was last read. 1: a refresh error has been detected since the register was last read. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????res
549 32015a-avr32-02/07 AT32AP7001 29.8.10 sdramc memory device register register name :mdr access type : read/write ? md: memory device type 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?????? md 00 sdram 01 low-power sdram 10 reserved 11 reserved.
550 32015a?avr32?02/07 AT32AP7001 30. error corrected code (ecc) controller rev: 1.0.0.0 30.1 features ? hardware error corrected code (ecc) generation ? detection and correction by software ? supports nand flash and smartmedia ? devices with 8- or 16-bit data path. ? supports nand flash/smartmedia with page size s of 528, 1056, 2112 and 4224 bytes, specified by software 30.2 description nand flash/smartmedia devices contain by default invalid blocks which have one or more invalid bits. over the nand flash/smartmedia lifetime, additional invalid blocks may occur which can be detected/corrected by ecc code. the ecc controller is a mechanism that encodes data in a manner that makes possible the identification and correction of certain errors in data. the ecc controller is capable of single bit error correction and 2-bit random detection. w hen nand flash/smartmedia have more than 2 bits of errors, the data cannot be corrected. the ecc user interface is accesi ble through the peripheral bus. 30.3 block diagram figure 30-1. block diagram user interface ctrl/ecc algorithm static memory controller peripheral bus nand flash smartmedia logic ecc controller
551 32015a?avr32?02/07 AT32AP7001 30.4 functional description a page in nand flash and smartmedia memories contains an area for main data and an addi- tional area used for redundancy (ecc). the page is organized in 8-bit or 16-bit words. the page size corresponds to the number of words in the main data plus the number of words in the extra area used for redundancy. the only configuration requir ed for ecc is the nand flash or the smartmedia page size (528/1056/2112/4224). page size is configured setting the pagesize field in the ecc mode register (mr). ecc is automatically computed as soon as a read (00h)/write (80h) command to the nand flash or the smartmedia is detected. read and write access must start at a page boundary. ecc is computed as soon as the counter reaches the page size. values in the ecc parity reg- ister (pr) and ecc nparity register (npr) are then valid and locked until a new start condition (read/write command followed by five access address cycles). 30.4.1 write access once the flash memory page is written, the computed ecc code is available in the ecc parity error (pr) and ecc_nparity error (npr) registers. the ecc code value must be written by the software application at the end of the page, in the extra area used for redundancy. 30.4.2 read access after reading main data in the page area, the application can perform read access to the extra area used for redundancy. error detection is automatically performed by the ecc controller. the application can check the ecc status register (sr) for any detected errors. it is up to the application to correct any detected error. ecc computation can detect four differ- ent circumstances: ? no error: xor between the ecc computation and the ecc code stored at the end of the nand flash or smartmedia page is equal to 0. no error flags in the ecc status register (sr). ? recoverable error: only the recerr flag in the ecc status register (sr) is set. the corrupted word offset in the read page is defined by the wordaddr field in the ecc parity register (pr). the corrupted bit position in the concerned word is defined in the bitaddr field in the ecc parity register (pr). ? ecc error: the eccerr flag in the ecc status register is set. an error has been detected in the ecc code stored in the flash memory. the position of the corrupted bit can be found by the application performing an xor between the parity and the nparity contained in the ecc code stored in the flash memory. ? non correctable error: the mulerr flag in the ecc status register is set. several unrecoverable errors have been detected in the flash memory page. ecc status register, ecc parity register and ecc nparity register are cleared when a read/write command is detected or a software register is enabled. for single bit error correction and double bit erro r detection (sec-ded) hsiao code is used. 32- bit ecc is generated in order to perform one bit correction per 512/1024/2048/4096 8- or 16-bit
552 32015a?avr32?02/07 AT32AP7001 words. of the 32 ecc bits, 26 bits are for line parity and 6 bits are for column parity. they are generated according to the schemes shown in figure 30-2 and figure 30-3 . figure 30-2. parity generation for 512/1024/2048/4096 8-bit words1 to calculate p8? to px? and p8 to px, apply the algorithm that follows. page size = 2 n for i =0 to n begin for (j = 0 to page_size_byte) begin if(j[i] ==1) p[2 i+3 ]=bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 i+3 ] else p[2 i+3 ]?=bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 i+3 ]' end end bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8 p8' bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8 p8' p16 p16' bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8 p8' bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 p8 p8' p16 p16' p32 p32 1st byte p32 2nd byte 3rd byte 4 th byte page size th byte (page size -1 )th byte px px' page size = 512 px = 2048 page size = 1024 px = 4096 page size = 2048 px = 8192 page size = 4096 px = 16384 (page size -2 )th byte (page size -3 )th byte p1 p1' p1' p1 p1 p1' p1' p1 p2 p2' p2 p2' p4 p4' p1=bit7(+)bit5(+)bit3(+)bit1(+)p1 p2=bit7(+)bit6(+)bit3(+)bit2(+)p2 p4=bit7(+)bit6(+)bit5(+)bit4(+)p4 p1'=bit6(+)bit4(+)bit2(+)bit0(+)p1' p2'=bit5(+)bit4(+)bit1(+)bit0(+)p2' p4'=bit7(+)bit6(+)bit5(+)bit4(+)p4'
553 32015a?avr32?02/07 AT32AP7001 figure 30-3. parity generation for 512/1024/2048/4096 16-bit words 1st word 2nd word 3rd word 4th word (page size -3 )th word (page size -2 )th word (page size -1 )th word page size th word (+) (+)
554 32015a?avr32?02/07 AT32AP7001 to calculate p8? to px? and p8 to px, apply the algorithm that follows. page size = 2 n for i =0 to n begin for (j = 0 to page_size_word) begin if(j[i] ==1) p[2 i+3 ]= bit15(+)bit14(+)bit13(+)bit12(+) bit11(+)bit10(+)bit9(+)bit8(+) bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 n+3 ] else p[2 i+3 ]?=bit15(+)bit14(+)bit13(+)bit12(+) bit11(+)bit10(+)bit9(+)bit8(+) bit7(+)bit6(+)bit5(+)bit4(+)bit3(+) bit2(+)bit1(+)bit0(+)p[2 i+3 ]' end end
555 32015a?avr32?02/07 AT32AP7001 30.5 ecc user interface table 30-1. ecc register mapping offset register register name access reset 0x00 ecc control register cr write-only 0x0 0x04 ecc mode register mr read/write 0x0 0x8 ecc status register sr read-only 0x0 0x0c ecc parity register pr read-only 0x0 0x10 ecc nparity register npr read-only 0x0 0x14-0xf8 reserved ? ? ? 0x14 - 0xfc reserved ? ? ?
556 32015a?avr32?02/07 AT32AP7001 30.5.1 ecc control register name: cr access type: write-only ? rst: reset parity provides reset to current ecc by software. 0: no effect 1: reset secc parity and ecc nparity register 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????rst
557 32015a?avr32?02/07 AT32AP7001 30.5.2 ecc mode register register name :mr access type : read/write ? pagesize: page size this field defines the page size of the nand flash device. a word has a value of 8 bits or 16 bits, depending on the nand flash or smartmedia memory organization. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?????? pagesize page size description 00 528 words 01 1056 words 10 2112 words 11 4224 words
558 32015a?avr32?02/07 AT32AP7001 30.5.3 ecc status register register name :sr access type : read-only ? recerr: recoverable error 0: no errors detected 1: errors detected. if mulerr is 0, a single correctable error was detected. otherwise multiple uncorrected errors were detected ? eccerr: ecc error 0: no errors detected 1: a single bit error occurred in the ecc bytes. read both ecc parity and ecc parityn register, the error occurred at the location which contains a 1 in the least significant 16 bits. ? mulerr: multiple error 0: no multiple errors detected 1: multiple errors detected 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?????mulerreccerrrecerr
559 32015a?avr32?02/07 AT32AP7001 30.5.4 ecc parity register register name :pr access type : read-only during a page write, the value of the entire register must be written in the extra area used for redundancy (for a 512-byte page size: address 512-513) ? bitaddr during a page read, this value contains the corrupted bit offset where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. ? wordaddr during a page read, this value contains the word address (8-bit or 16-bit word depending on the memory plane organiza- tion) where an error occurred, if a single error was detected. if multiple errors were detected, this value is meaningless. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 wordaddr 76543210 wordaddr bitaddr
560 32015a?avr32?02/07 AT32AP7001 30.5.5 ecc nparity register register name :npr access type : read-only ? nparity: during a write, the value of this register must be written in the extra area used for redundancy (for a 512-byte page size: address 514-515) 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 nparity 76543210 nparity
561 32015a?avr32?02/07 AT32AP7001 31. multimedia card interface (mci) rev: 2.1.0.0 31.1 features ? compatible with multimedia card specification version 2.2 ? compatible with sd memory card specification version 1.0 ? compatible with multimedia card specification version 3.31 ? compatible with sdio specification version 1.1 ? cards clock rate up to ma ster clock divided by 2 ? embedded power management to slow down clock rate when not used ? supports 2 multiplexed slot(s) ? each slot for either a multimediacard bus (up to 30 cards) or an sd memory card ? support for stream, block and mu lti-block data read and write ? supports connection to dma controller ? minimizes processor interventi on for large buffer transfers 31.2 description the mci includes a command register, response registers, data registers, timeout counters and error detection logic that automatically handle the transmission of commands and, when required, the reception of the associated responses and data with a limited processor overhead. the mci supports stream, block and multi-block data read and write, and is compatible with a dma controller, minimizing processor intervention for large buffer transfers. the mci operates at a rate of up to master cloc k divided by 2 and supports the interfacing of 2 slot(s). each slot may be used to interface with a multimedia card bus (up to 30 cards) or with a sd memory card. only one slot can be selected at a time (slots are multiplexed). a bit field in the sd card register performs this selection. the sd memory card communication is based on a 9-pin interface (clock, command, four data and three power lines) and the multimediacard on a 7-pin interface (clock, command, one data, three power lines and one reserved for future use). the sd memory card interface also supports multimedia card operations. the main differences between sd and multimedia cards are the initialization process and the bus topology.
562 32015a?avr32?02/07 AT32AP7001 31.3 block diagram figure 31-1. block diagram note: 1. when several mci (x mci) are embedded in a product, mcck refers to mci x ck, mccda to mci x cda, mcday to mcix day, mcdby to mcix dby mci interface interrupt control pio pdc / dma peripheral bus bridge pm mck mci interrupt mcck mccda mcda0 mcda1 mcda2 mcda3 (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) mccdb mcdb0 mcdb1 mcdb2 mcdb3 peripheral bus
563 32015a?avr32?02/07 AT32AP7001 31.4 application block diagram figure 31-2. application block diagram 31.5 pin name list note: 1. i: input, o: output, pp: push/pull, od: open drain. 23456 17 mmc 23456 17 8 sdcard 9 physical layer mci interface application layer ex: file system, audio, security, etc. table 31-1. i/o lines description pin name pin description type (1) comments mccda/mccdb command/response i/o/pp/ od cmd of an mmc or sd card mcck clock i/o clk of an mmc or sd card mcda0 - mcda3 data 0..3 of slot a i/o/pp dat0 of an mmc dat[0..3] of an sd card mcdb0 - mcdb3 data 0..3 of slot b i/o/pp dat0 of an mmc dat[0..3] of an sd card
564 32015a?avr32?02/07 AT32AP7001 31.6 product dependencies 31.6.1 i/o lines the pins used for interfacing the multimedia cards or sd cards may be multiplexed with pio lines. the programmer must first program the pio controllers to assign the peripheral functions to mci pins. 31.6.2 power management the mci may receive a clock from the power manager (pm), so the programmer must first con- figure the pm to enable the mci clock. 31.6.3 interrupt the mci interface has an interrupt line connected to the interrupt controller (intc). handling the mci interrupt requires programming the intc before configuring the mci. 31.7 bus topology figure 31-3. multimedia memory card bus topology the multimedia card communication is based on a 7- pin serial bus interface. it has three com- munication lines and four supply lines. note: 1. i: input, o: output, pp : push/pull, od: open drain. 2. when several mci (x mci) are embedded in a product, mcck refers to mci x ck, mccda to mci x cda, mcday to mcix day, mcdby to mcix dby table 31-2. bus topology pin number name type (1) description mci pin name (slot x) 1 rsv nc not connected 2 cmd i/o/pp/od command/response mccdx 3 vss1 s supply voltage ground vss 4 vdd s supply voltage vdd 5 clk i/o clock mcck 6 vss2 s supply voltage ground vss 7 dat[0] i/o/pp data 0 mcdx0 23456 17 mmc
565 32015a?avr32?02/07 AT32AP7001 figure 31-4. mmc bus connections (one slot) note: 1. when several mci (x mci) are embedded in a product, mcck refers to mci x ck, mccda to mci x cda, mcday to mcix day figure 31-5. sd memory card bus topology the sd memory card bus includes the signals listed in table 31-3 on page 565 . note: 1. i: input, o: output, pp: push pull, od: open drain table 31-3. sd memory card bus signals pin number name type (1) description mci pin name (slot x) 1 cd/dat[3] i/o/pp card detect/ data line bit 3 mcdx3 2 cmd pp command/response mccdx 3 vss1 s supply voltage ground vss 4 vdd s supply voltage vdd 5 clk i/o clock mcck 6 vss2 s supply voltage ground vss 7 dat[0] i/o/pp data line bit 0 mcdx0 8 dat[1] i/o/pp data line bit 1 or interrupt mcdx1 9 dat[2] i/o/pp data line bit 2 mcdx2 23456 1 7 23456 1 7 23456 17 mcda0 mccda mcck mmc1 mmc2 mmc3 mci 23456 17 8 sd card 9
566 32015a?avr32?02/07 AT32AP7001 figure 31-6. sd card bus connections with two slots note: 1. when several mci (x mci) are embedded in a product, mcck refers to mci x ck, mccda to mci x cda, mcday to mcix day, mcdby to mcix dby figure 31-7. mixing multimedia and sd memory cards with two slots note: 1. when several mci (x mci) are embedded in a product, mcck refers to mci x ck, mccda to mci x cda, mcday to mcix day, mcdby to mcix dby when the mci is configured to operate with sd memory cards, the width of the data bus can be selected in the sdcr regi ster. clearing the sdcbus bit in this register means that the width is one bit; setting it means that the width is four bits. in the case of multimedia cards, only the data line 0 is used. the other data lines can be used as independent pios. 23456 17 mcda0 - mcda3 mccda mcck 8 sd card 1 9 23456 17 8 sd card 2 9 mcdb0 - mcdb3 mccdb 23456 1 7 23456 1 7 23456 17 mmc1 mmc2 mmc3 mcda0 mcck mccda 23456 17 8 sd card 9 mcdb0 - mcdb3 mccdb
567 32015a?avr32?02/07 AT32AP7001 31.8 multimedia card operations after a power-on reset, the cards are initialized by a special message-based multimedia card bus protocol. each message is represented by one of the following tokens: ? command: a command is a token that starts an operation. a command is sent from the host either to a single card (addressed command) or to all connected cards (broadcast command). a command is transferred serially on the cmd line. ? response: a response is a token which is sent from an addressed card or (synchronously) from all connected cards to the host as an answer to a previously received command. a response is transferred serially on the cmd line. ? data: data can be transferred from the card to the host or vice versa. data is transferred via the data line. card addressing is implemented using a sess ion address assigned during the initialization phase by the bus controller to all currently connected cards. their unique cid number identifies individual cards. the structure of commands, resp onses and data blocks is descr ibed in the multimedia-card system specification. see also table 31-4 on page 568 . multimediacard bus data transfers are composed of these tokens. there are different types of operations. addressed operations always contain a command and a response token. in addition, some operations have a data token; the others transfer their infor- mation directly within the command or response structure. in this case, no data token is present in an operation. the bits on the dat and the cmd lines are transferred synchronous to the mci clock. two types of data transfer commands are defined: ? sequential commands: these commands initiate a continuous data stream. they are terminated only when a stop command follows on the cmd line. this mode reduces the command overhead to an absolute minimum. ? block-oriented commands: these commands send a data block succeeded by crc bits. both read and write operations allow either single or multiple block transmission. a multiple block transmission is terminated when a stop co mmand follows on the cm d line similarly to the sequential read or when a multiple block transmission has a predefined block count ( see ?data transfer operation? on page 569. ). the mci provides a set of registers to perform the entire range of multimedia card operations. 31.8.1 command - response operation after reset, the mci is disabled and becomes va lid after setting the mcien bit in the cr (mci control register). the pwsen bit saves power by dividing the mci clock by 2 pwsdiv + 1 when the bus is inactive. the two bits rdproof and wrproof in the mci mode register (mr) allow stopping the mci clock during read or write access if the internal fi fo is full. this will guaran tee data integrity, not bandwidth. the command and the response of the card are clocked out with the rising edge of the mci clock.
568 32015a?avr32?02/07 AT32AP7001 all the timings for multimedia card are defined in the multim ediacard system specification. the two bus modes (open drain and push/pull) needed to process all the operations are defined in the mci command register. the cmdr allows a command to be carried out. for example, to perform an all_send_cid command: the command all_send_cid and the fields and values for the cmdr control register are described in table 31-4 and table 31-5 . note: bcr means broadcast command with response. the argr contains the argument field of the command. to send a command, the user must perform the following steps: ? fill the argument register (a rgr) with the command argument. ? set the command register (cmdr) (see table 31-5 ). the command is sent immediately after writing the command register. the status bit cmdrdy in the status register (sr) is asserted when the command is completed. if the command requires a response, it can be read in the mci response register (rspr). the response size can be from 48 bits up to 136 bits depending on the command. the mci embeds an error detection to pre- vent any corrupted data during the transfer. host command n id cycles cid cmd s t content crc e z ****** z s t content z z z table 31-4. all_send_cid command description cmd index type argument resp abbreviation command description cmd2 bcr [31:0] stuff bits r2 all_send_cid asks all cards to send their cid numbers on the cmd line table 31-5. fields and values for cmdr command register field value cmdnb (command number) 2 (cmd2) rsptyp (response type) 2 (r2: 136 bits response) spcmd (special command) 0 (not a special command) opcmd (open drain command) 1 maxlat (max latency for command to response) 0 (nid cycles ==> 5 cycles) trcmd (transfer command) 0 (no transfer) trdir (transfer direction) x (available only in transfer command) trtyp (transfer type) x (available only in transfer command)
569 32015a?avr32?02/07 AT32AP7001 the following flowchart shows how to send a command to the card and read the response if needed. in this example, the status register bits are polled but setting the appropriate bits in the interrupt enable register (ier) allows using an interrupt method. figure 31-8. command/response functional flow diagram note: 1. if the command is send_op_cond, the crc error flag is always present (refer to r3 response in the multimedi a card specification). 31.8.2 data transfer operation the multimedia card allo ws several read/write operations (single block, multiple blocks, stream, etc). these kind of transfers can be selected setting the transfer type (trtyp) field in the mci command register (cmdr). these operations can be done using the a dma controller. in all cases, the block length (blklen field) must be defined either in the mode register mr, or in the block register blkr. this field determines the size of the data block. return ok return error (1) set the command argument mci_argr = argument (1) set the command mci_cmdr = command read mci_sr cmdrdy status error flags? read response if required ye s wait for command ready status flag check error bits in the status register (1) 0 1
570 32015a?avr32?02/07 AT32AP7001 consequent to mmc specification 3.1, two types of multiple block read (or write) transactions are defined (the host can use either one at any time): ? open-ended/infinite multiple block read (or write): the number of blocks for the read (or write) multiple block operation is not defined. the card will continuously transfer (or program) dat a blocks until a stop transmission command is received. ? multiple block read (or write) with pre-defined block count (since version 3.1 and higher): the card will transfer (or program) the requested number of data blocks and terminate the transaction. the stop command is not required at the end of this type of multiple block read (or write), unless terminated with an error. in or der to start a multiple bl ock read (or write) with pre-defined block count, the host must correctl y program the mci block register (blkr). otherwise the card will st art an open-ended multip le block read. the bcnt field of the block register defines the number of blocks to tran sfer (from 1 to 65535 blocks). programming the value 0 in the bcnt field corresponds to an infinite block transfer. 31.8.3 read operation the following flowchart shows how to read a single block with or without us e of dma facilities. in this example, a polling method is used to wait for the end of read. similarly, the user can config- ure the interrupt enable register (ier) to trigger an interrupt at the end of read.
571 32015a?avr32?02/07 AT32AP7001 figure 31-9. read functional flow diagram note: 1. this command is supposed to have been correctly sent (see figure 31-8 ). 31.8.4 write operation in write operation, the mci mode register (mr) is used to define the padding value when writing non-multiple block size. if the bit dmapadv is 0, then 0x00 value is us ed when padding data, otherwise 0xff is used. read status register mci_sr send command sel_desel_card to select the card send command set_blocklen read with dma reset the pdcmode bit mci_mr &= ~pdcmode set the block length (in bytes) mci_mr |= (blocklenght <<16) number of words to read = 0 ? poll the bit rxrdy = 0? read data = mci_rdr number of words to read = number of words to read -1 send command read_single_block (1) ye s set the block length (in bytes) mci_mr |= (blocklength << 16) configure the dma controller send command read_single_block (1) wait for data from mmc data received? no return ye s no no ye s ye s no number of words to read = blocklength/4 dma transfer complete ? no return ye s
572 32015a?avr32?02/07 AT32AP7001 the following flowchart shows how to write a singl e block with or without use of dma facilities. polling or interrupt method can be used to wait for the end of write according to the contents of the interrupt mask register (imr).
573 32015a?avr32?02/07 AT32AP7001 figure 31-10. write functional flow diagram note: 1. it is assumed that this command has been correctly sent (see figure 31-8 ). send command sel_desel_card to select the card send command set_blocklen reset the pdcmode bit mci_mr &= ~pdcmode set the block length mci_mr |= (blocklenght <<16) send command write_single_block (1) no read status register mci_sr number of words to write = 0 ? poll the bit txrdy = 0? mci_tdr = data to write number of words to write = number of words to write -1 ye s return no ye s no number of words to write = blocklength/4 write with dma set the block length (in bytes) mci_mr |= (blocklength << 16) configure the dma controller send command write_single_block (1) wait for data transfer to mmc complete data transmitted? no ye s ye s dma transfer complete ? no return ye s
574 32015a?avr32?02/07 AT32AP7001 31.9 sd card operations the multimedia card interface allows processing of sd memory (secure digital memory card) and sdio (sd input output) card commands. sd/sdio cards are based on the multi media card (mmc) format, but are physically slightly thicker and feature higher data transfer rates, a lock switch on the side to prevent accidental overwriting and security featur es. the physical form factor, pin assignment and data transfer protocol are forward-compatible with the multimedia card with some additions. sd slots can actually be used for more than flash memory ca rds. devices that support sdio can use small devices designed for the sd form factor, such as gps receivers, wi-fi or bluetooth adapters, modems, barcode readers, irda adapters, fm radio tuners, rfid readers, digital cameras and more. sd/sdio is covered by numerous patents and trademarks, and licensing is only available through the secure digital card association. the sd/sdio card communication is based on a 9-pin interface (clock, command, 4 x data and 3 x power lines). the communication protocol is defined as a part of this specification. the main difference between the sd/sdio card and t he multimedia card is the initialization process. the sd/sdio card register (sdcr) allows select ion of the card slot and the data bus width. the sd/sdio card bus allows dynamic configur ation of the number of data lines. after power up, by default, the sd/sdio card uses only dat0 for data transfer. after initialization, the host can change the bus width (number of active data lines). 31.9.1 sdio data transfer type sdio cards may transfer data in either a multi-byte (1 to 512 bytes) or an optional block format (1 to 511 blocks), while the sd memory cards are fixed in the block transfer mode. the trtyp field in the mci command register (cmdr) allows to choose between sdio byte or sdio block transfer. the number of bytes/blocks to transfer is set through the bcnt field in the mci block register (blkr). in sdio block mode, the field blklen must be set to the data block size while this field is not used in sdio byte mode. an sdio card can have multiple i/o or combined i/o and memo ry (called combo card). within a multi-function sdio or a combo card, there are multiple devices (i/o and memory) that share access to the sd bus. in order to allow the sharing of access to the host among multiple devices, sdio and combo cards can implement the optional concept of suspend/resume (refer to the sdio specification for more details). to send a suspend or a resume command, the host must set the sdio special command field (iospcmd) in the mci command register. 31.9.2 sdio interrupts each function within an sdio or combo card ma y implement interrupts (refer to the sdio spec- ification for more details). in order to allow the sdio card to interrupt the host, an interrupt function is added to a pin on the dat[1] line to si gnal the card?s interrupt to the host. an sdio interrupt on each slot can be enabled through the mci interrupt enable register. the sdio inter- rupt is sampled regardless of the currently selected slot.
575 32015a?avr32?02/07 AT32AP7001 31.10 multimedia card inte rface (mci) user interface note: 1. the response register can be read by n accesses at the same rspr or at consecutive addresses (0x20 to 0x2c). n depends on the size of the response. table 31-6. register mapping offset register register name read/write reset 0x00 control register cr write ? 0x04 mode register mr read/write 0x0 0x08 data timeout register dtor read/write 0x0 0x0c sd/sdio card register sdcr read/write 0x0 0x10 argument register argr read/write 0x0 0x14 command register cmdr write ? 0x18 block register blkr read/write - 0x1c reserved ? ? ? 0x20 response register (1) rspr read 0x0 0x24 response register (1) rspr read 0x0 0x28 response register (1) rspr read 0x0 0x2c response register (1) rspr read 0x0 0x30 receive data register rdr read 0x0 0x34 transmit data register tdr write ? 0x38 - 0x3c reserved ? ? ? 0x40 status register sr read 0xc0e5 0x44 interrupt enable register ier write ? 0x48 interrupt disable register idr write ? 0x4c interrupt mask register imr read 0x0
576 32015a?avr32?02/07 AT32AP7001 31.10.1 mci control register name: cr access type: write-only ? mcien: multi-media interface enable 0 = no effect. 1 = enables the multi-media interface if mcdis is 0. ? mcidis: multi-media interface disable 0 = no effect. 1 = disables the multi-media interface. ? pwsen: power save mode enable 0 = no effect. 1 = enables the power saving mode if pwsdis is 0. warning: before enabling this mode, the user must set a value different from 0 in the pwsdiv field (mode register mr) . ? pwsdis: power save mode disable 0 = no effect. 1 = disables the power saving mode. ? swrst: software reset 0 = no effect. 1 = resets the mci. a software triggered hardware reset of the mci interface is performed. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 swrst ? ? ? pwsdis pwsen mcidis mcien
577 32015a?avr32?02/07 AT32AP7001 31.10.2 mci mode register name: mr access type: read/write ? clkdiv: clock divider multimedia card interface clock (mcck) is master clock (mck) divided by (2*(clkdiv+1)). ? pwsdiv: power saving divider multimedia card interface clock is divided by 2 (pwsdiv) + 1 when entering power saving mode. warning: this value must be different from 0 before enabling the power save mode in the cr (pwsen bit). ? rdproof read proof enable enabling read proof allows to stop the mci clock during read acce ss if the internal fifo is full. this will guarantee data integrity, no t bandwidth. 0 = disables read proof. 1 = enables read proof. ? wrproof write proof enable enabling write proof allows to stop the mci clock during write ac cess if the internal fifo is full. this will guarantee data integrity, no t bandwidth. 0 = disables write proof. 1 = enables write proof. ? dmapadv: dma padding value 0 = 0x00 value is used when padding data in write transfer. 1 = 0xff value is used when padding data in write transfer. ? blklen: data block length this field determines the size of the data block. this field is also accessible in the mci block register (blkr). bits 16 and 17 must be written to 0. note: in sdio byte mode, blklen field is not used. 31 30 29 28 27 26 25 24 blklen 23 22 21 20 19 18 17 16 blklen 15 14 13 12 11 10 9 8 - dmapadv ? wrproof rdproof pwsdiv 76543210 clkdiv
578 32015a?avr32?02/07 AT32AP7001 31.10.3 mci data timeout register name: dtor access type: read/write ? dtocyc: data timeout cycle number ? dtomul: data ti meout multiplier these fields determine the maximum number of master clock cycles that the mci waits between two data block transfers. it equals (dtocyc x multiplier). multiplier is defined by dtomul as shown in the following table: if the data time-out set by dtocyc and dtomul has been exceeded, the data time-out error flag (dtoe) in the mci status register (sr) raises. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? dtomul dtocyc dtomul multiplier 0001 00116 010128 011256 1001024 1014096 1 1 0 65536 1 1 1 1048576
579 32015a?avr32?02/07 AT32AP7001 31.10.4 mci sd card/sdio register name: sdcr access type: read/write ? sdcsel: sd card selector 0 = sdcard slot a selected. 1= sdcard slot b selected. ? sdcbus: sd card/sdio bus width 0 = 1-bit data bus 1 = 4-bit data bus 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 sdcbus ? ? ? sdcsel
580 32015a?avr32?02/07 AT32AP7001 31.10.5 mci argument register name: argr access type: read/write ? arg: command argument 31 30 29 28 27 26 25 24 arg 23 22 21 20 19 18 17 16 arg 15 14 13 12 11 10 9 8 arg 76543210 arg
581 32015a?avr32?02/07 AT32AP7001 31.10.6 mci command register name: cmdr access type: write-only this register is write-protecte d while cmdrdy is 0 in sr. if an interrupt command is sent, this register is only writeable by an interrupt response (field spcmd). this means that the current command execution cannot be interrupted or modified. ? cmdnb: command number ? rsptyp: response type ? ? spcmd: special command ? opdcmd: open drain command 0 = push pull command 31 30 29 28 27 26 25 24 ?????? iospcmd 23 22 21 20 19 18 17 16 ? ? trtyp trdir trcmd 15 14 13 12 11 10 9 8 ? ? ? maxlat opdcmd spcmd 76543210 rsptyp cmdnb rsp response type 0 0 no response. 0 1 48-bit response. 1 0 136-bit response. 1 1 reserved. spcmd command 0 0 0 not a special cmd. 001 initialization cmd: 74 clock cycles for in itialization sequence. 010 synchronized cmd: wait for the end of the current data block transfer before sending the pending command. 011reserved. 100 interrupt command: corresponds to the interrupt mode (cmd40). 101 interrupt response: corresponds to the interrupt mode (cmd40).
582 32015a?avr32?02/07 AT32AP7001 1 = open drain command ? maxlat: max latency for command to response 0 = 5-cycle max latency 1 = 64-cycle max latency ? trcmd: transfer command ? trdir: transfer direction 0 = write 1 = read ? trtyp: transfer type ? iospcmd: sdio special command trcmd transfer type 0 0 no data transfer 0 1 start data transfer 1 0 stop data transfer 11reserved trtyp transfer type 0 0 0 mmc/sdcard single block 0 0 1 mmc/sdcard multiple block 010mmc stream 0 1 1 reserved 1 0 0 sdio byte 101sdio block 1 1 0 reserved 1 1 1 reserved iospcmd sdio special command type 0 0 not a sdio special command 0 1 sdio suspend command 1 0 sdio resume command 11reserved
583 32015a?avr32?02/07 AT32AP7001 31.10.7 mci block register name: blkr access type: read/write ? bcnt: mmc/sdio block count - sdio byte count this field determines the number of data byte(s) or block(s) to transfer. the transfer data type and the authorized values for bcnt field are determined by the trtyp field in the mci command register (cmdr): warning: in sdio byte and block modes, writing to the 7 last bi ts of bcnt field, is forbidden and may lead to unpredict- able results. ? blklen: data block length this field determines the size of the data block. this field is also accessible in the mci mode register (mr). bits 16 and 17 must be set to 0 if pdcfbyte is disabled. note: in sdio byte mode, blklen field is not used. 31 30 29 28 27 26 25 24 blklen 23 22 21 20 19 18 17 16 blklen 15 14 13 12 11 10 9 8 bcnt 76543210 bcnt trtyp type of transfer bcnt authorized values 0 0 1 mmc/sdcard multiple block from 1 to mci_maxnum_blk: value 0 corresponds to an infinite block transfer. 1 0 0 sdio byte from 1 to 512 bytes: value 0 corresponds to a 512-byte transfer. values from 0x200 to 0xffff are forbidden. 1 0 1 sdio block from 1 to 511 blocks: value 0 corresponds to an infinite block transfer. values from 0x200 to 0xffff are forbidden. other values - reserved.
584 32015a?avr32?02/07 AT32AP7001 31.10.8 mci response register name: rspr access type: read-only ? rsp: response note: 1. the response register can be read by n accesses at the same rspr or at consecutive addresses (0x20 to 0x2c). n depends on the size of the response. 31 30 29 28 27 26 25 24 rsp 23 22 21 20 19 18 17 16 rsp 15 14 13 12 11 10 9 8 rsp 76543210 rsp
585 32015a?avr32?02/07 AT32AP7001 31.10.9 mci receive data register name: rdr access type: read-only ? data: data to read 31 30 29 28 27 26 25 24 data 23 22 21 20 19 18 17 16 data 15 14 13 12 11 10 9 8 data 76543210 data
586 32015a?avr32?02/07 AT32AP7001 31.10.10 mci transmit data register name: tdr access type: write-only ? data: data to write 31 30 29 28 27 26 25 24 data 23 22 21 20 19 18 17 16 data 15 14 13 12 11 10 9 8 data 76543210 data
587 32015a?avr32?02/07 AT32AP7001 31.10.11 mci status register name: sr access type: read-only ? cmdrdy: command ready 0 = a command is in progress. 1 = the last command has been sent. cleared when writing in the cmdr. ? rxrdy: receiver ready 0 = no data has been received since the last read of rdr. 1 = data has been received since the last read of rdr. ? txrdy: transmit ready 0= the last data written in tdr has not yet been transferred in the shift register. 1= the last data written in tdr has been transferred in the shift register. ? blke: data block ended this flag must be used only for write operations. 0 = a data block transfer is not yet finished. cleared when reading the sr. 1 = a data block transfer has ended, including the crc16 status transmission. the flag is set for each transmitted crc status. refer to the mmc or sd sp ecification for more details concerning the crc status. for the read operations, the blke flag is set for each received crc. ? dtip: data transfer in progress 0 = no data transfer in progress. 1 = the current data tran sfer is still in progress, including crc16 calculatio n. cleared at the end of the crc16 calculation. ? notbusy: data not busy this flag must be used only for write operations. a block write operation uses a simple busy signalling of the write operat ion duration on the data (dat0) line: during a data transfer block, if the card does not have a free data receive buffer, the card indicates this condition by pulling down the dat a line (dat0) to low. the card stops pulling down the data line as soon as at least one receive buffer for the defined data transfer block length becomes free. the notbusy flag allows to deal with these different states. 31 30 29 28 27 26 25 24 unreovre?????? 23 22 21 20 19 18 17 16 ? dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 --?? - - sdioirqb sdioirqa 76543210 - - notbusy dtip blke txrdy rxrdy cmdrdy
588 32015a?avr32?02/07 AT32AP7001 0 = the mci is not ready for new data transfer. cleared at the end of the card response. 1 = the mci is ready for new data transfer. set when the busy state on the data line has ended. this corresponds to a free internal data receive buffer of the card. refer to the mmc or sd specification for more details concerning the busy behavior. for all the read operations, the notbusy flag is cleared at the end of the host command. for the infinite read multiple blocks, the notbusy flag is set at the end of the st op_transmission host command (cmd12). for the single block reads, the notbusy flag is set at the end of the data read block. for the multiple block reads with pre-defined block count, the notbusy flag is set at the end of the last received data block. ? rinde: response index error 0 = no error. 1 = a mismatch is detected between the command index sent and the response index received. cleared when writing in the cmdr. ? rdire: response direction error 0 = no error. 1 = the direction bit from card to host in the response has not been detected. ? rcrce: response crc error 0 = no error. 1 = a crc7 error has been detected in the response. cleared when writing in the cmdr. ? rende: response end bit error 0 = no error. 1 = the end bit of the response has not been detected. cleared when writing in the cmdr. ? rtoe: response time-out error 0 = no error. 1 = the response time-out set by maxlat in the cmdr has been exceeded. cleared when writing in the cmdr. ? dcrce: data crc error 0 = no error. 1 = a crc16 error has been detected in the last data block. cleared when reading sr. ? dtoe: data time-out error 0 = no error. 1 = the data time-out set by dtocyc and dtomul in dtor has been exceeded. cleared when reading sr. ? ovre: overrun 0 = no error. 1 = at least one 8-bit received data has been lost (not read). cleared when sending a new data transfer command. ? unre: underrun 0 = no error. 1 = at least one 8-bit data has been sent without valid inform ation (not written). cleared when sending a new data transfer command.
589 32015a?avr32?02/07 AT32AP7001 ? sdioirqa: sdio interrupt for slot a 0 = no interrupt detected on sdio slot a. 1 = a sdio interrupt on slot a has reached. cleared when reading the sr. ? sdioirqb: sdio interrupt for slot b 0 = no interrupt detected on sdio slot b. 1 = a sdio interrupt on slot b has reached. cleared when reading the sr.
590 32015a?avr32?02/07 AT32AP7001 31.10.12 mci interrupt enable register name: ier access type: write-only ? cmdrdy: command ready interrupt enable ? rxrdy: receiver ready interrupt enable ? txrdy: transmit ready interrupt enable ? blke: data block ended interrupt enable ? dtip: data transfer in progress interrupt enable ? notbusy: data not busy interrupt enable ? sdioirqa: sdio interrupt for slot a interrupt enable ? sdioirqb: sdio interrupt for slot b interrupt enable ? rinde: response index er ror interrupt enable ? rdire: response direction error interrupt enable ? rcrce: response crc error interrupt enable ? rende: response end bit error interrupt enable ? rtoe: response time-out error interrupt enable ? dcrce: data crc error interrupt enable ? dtoe: data time-out error interrupt enable ? ovre: overrun in terrupt enable ? unre: underrun interrupt enable 0 = no effect. 1 = enables the corresponding interrupt. 31 30 29 28 27 26 25 24 unreovre?????? 23 22 21 20 19 18 17 16 ? dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 - - ???? sdioirqb sdioirqa 76543210 - - notbusy dtip blke txrdy rxrdy cmdrdy
591 32015a?avr32?02/07 AT32AP7001 31.10.13 mci interrupt disable register name: idr access type: write-only ? cmdrdy: command ready interrupt disable ? rxrdy: receiver ready interrupt disable ? txrdy: transmit ready interrupt disable ? blke: data block ended interrupt disable ? dtip: data transfer in progress interrupt disable ? notbusy: data not busy interrupt disable ? sdioirqa: sdio interrupt for slot a interrupt enable ? sdioirqb: sdio interrupt for slot b interrupt enable ? rinde: response index er ror interrupt disable ? rdire: response direction error interrupt disable ? rcrce: response crc error interrupt disable ? rende: response end bit error interrupt disable ? rtoe: response time-out error interrupt disable ? dcrce: data crc error interrupt disable ? dtoe: data time-out er ror interrupt disable ? ovre: overrun in terrupt disable ? unre: underrun interrupt disable 0 = no effect. 1 = disables the corresponding interrupt. 31 30 29 28 27 26 25 24 unreovre?????? 23 22 21 20 19 18 17 16 ? dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 - - ???? sdioirqb sdioirqa 76543210 - - notbusy dtip blke txrdy rxrdy cmdrdy
592 32015a?avr32?02/07 AT32AP7001 31.10.14 mci interrupt mask register name: imr access type: read-only ? cmdrdy: command ready interrupt mask ? rxrdy: receiver ready interrupt mask ? txrdy: transmit ready interrupt mask ? blke: data block ended interrupt mask ? dtip: data transfer in progress interrupt mask ? notbusy: data not busy interrupt mask ? sdioirqa: sdio interrupt for slot a interrupt enable ? sdioirqb: sdio interrupt for slot b interrupt enable ? rinde: response index error interrupt mask ? rdire: response directio n error interrupt mask ? rcrce: response crc error interrupt mask ? rende: response end bit error interrupt mask ? rtoe: response time-out error interrupt mask ? dcrce: data crc error interrupt mask ? dtoe: data time-out error interrupt mask ? ovre: overrun interrupt mask ? unre: underrun interrupt mask 0 = the corresponding interrupt is not enabled. 1 = the corresponding interrupt is enabled. 31 30 29 28 27 26 25 24 unreovre?????? 23 22 21 20 19 18 17 16 ? dtoe dcrce rtoe rende rcrce rdire rinde 15 14 13 12 11 10 9 8 - - ???? sdioirqb sdioirqa 76543210 - - notbusy dtip blke txrdy rxrdy cmdrdy
593 32015a?avr32?02/07 AT32AP7001 32. usb device - high speed (480 mbits/s) rev: 1.4.0.0 32.1 features ? usb v2.0 high speed compli ant, 480 mbits per second ? utmi compliant ? 7 endpoints ? embedded dual-port ram for endpoints ? suspend/resume logic (command of utmi) ? up to three memory banks for endpoints (not for control endpoint) ? 4 kbytes of dpram ? compatible with embedded arm9tdmi ? processor 32.2 description the usb high speed device (usba) is compliant with the universal serial bus (usb), rev 2.0 high speed device specification. each endpoint can be configured in one of several usb transfer types. it can be associated with one, two or three banks of a dual-port ram used to store the current data payload. if two or three banks are used, one dpr bank is read or written by the processor, while the other is read or written by the usb device peripheral. this f eature is mandatory for isochronous endpoints. the default size of the dpram is 4 kb. suspend and resume are automatically detected by the usba device, which notifies the proces- sor by raising an interrupt. table 32-1. usba endpoint description endpoint # mnemonic nb bank dma high band width max. endpoint size endpoint type 0 ep0 1 n n 64 control 1 ep1 2 y y 512 ctrl/bulk/iso/interrupt 2 ep2 2 y y 512 ctrl/bulk/iso/interrupt 3 ep3 3 y n 64 ctrl/bulk/interrupt 4 ep4 3 y n 64 ctrl/bulk/interrupt 5 ep5 3 y y 1024 ctrl/bulk/interrupt 6 ep6 3 y y 1024 ctrl/bulk/interrupt
594 32015a?avr32?02/07 AT32AP7001 32.3 block diagram figure 32-1. block diagram: 32 bits system clock domain usb clock domain ctrl status rd/wr/ready peripheral bus interface usb2.0 core ept alloc hsb1 dma hsb0 local hsb slave interface master hsb multiplexer slave dpram utmi 16/8 bits pb bus hsb bus hsb bus
595 32015a?avr32?02/07 AT32AP7001 32.4 typical connection figure 32-2. board schematic note: 1. values are guidelines only. actual values are tbd. table 32-2. components typical values symbol value (1) unit r1 6.8 1% k r2 39 1% c1 10 pf usb connector mini ab nc / d- / d+ / gnd hsdp hsdm fsdp fsdm bias r2 r2 r1 c1 1234
596 32015a?avr32?02/07 AT32AP7001 32.5 usb v2.0 high speed device introduction the usb v2.0 high speed device provides communication services to/from host when attached. each device is offered with a collection of communication flows (pipes) associated with each endpoint. software on the host communicates with a usb device through a set of commu- nication flows. 32.5.1 usb v2.0 high speed transfer types a communication flow is carried over one of f our transfer types defined by the usb device. a device provides several logical communication pipes with the host. to each logical pipe is associated an endpoint. transfer through a pipe belongs to one of the four transfer types: ? control transfers: used to configure a device at attach time and can be used for other device- specific purposes, including control of other pipes on the device. ? bulk data transfers: generated or consumed in relatively large burst quantities and have wide dynamic latitude in transmission constraints. ? interrupt data transfers: used for timely but reliable delivery of data, for example, characters or coordinates with human-perceptible echo or feedback response characteristics. ? isochronous data transfers: occupy a prenegotiated amount of usb bandwidth with a prenegotiated delivery latency. (also called streaming real time transfers.) as indicated below, transfers are sequential events carried out on the usb bus. endpoints must be configured according to the transfer type they handle. table 32-3. usb communication flow transfer direction bandwidth endpoin t size error detection retrying control bidirectional not guaranteed 8,16,32,64 yes automatic isochronous unidirectional guaranteed 8-1024 yes no interrupt unidirectional not guaranteed 8-1024 yes yes bulk unidirectional not guaranteed 8-512 yes yes
597 32015a?avr32?02/07 AT32AP7001 32.5.2 usb transfer event definitions a transfer is composed of one or several transactions; notes: 1. control transfer must use endpoints with one bank and can be aborted using a stall handshake. 2. isochronous transfers must use endpoint s configured with two or three banks. an endpoint handles all transactions related to the type of transfer for which it has been configured. 32.5.3 usb v2.0 high speed bus transactions each transfer results in one or more transactions over the usb bus. there are five kinds of transactions flowing across the bus in packets: 1. setup transaction 2. data in transaction 3. data out transaction 4. status in transaction 5. status out transaction table 32-4. usb transfer events control (bidirectional) control transfers (1) ? setup transaction > data in transactions > status out transaction ? setup transaction > data out tran sactions > status in transaction ? setup transaction > st atus in transaction in (device toward host) bulk in transfer ? data in transaction > data in transaction interrupt in transfer ? data in transaction > data in transaction isochronous in transfer (2) ? data in transaction > data in transaction out (host toward device) bulk out transfer ? data out transaction > data out transaction interrupt out transfer ? data out transaction > data out transaction isochronous out transfer (2) ? data out transaction > data out transaction
598 32015a?avr32?02/07 AT32AP7001 figure 32-3. control read and write sequences a status in or out transaction is identical to a data in or out transaction. 32.5.4 endpoint configuration the endpoint 0 is always a control endpoint, it must be programmed and active in order to be enabled when the end of reset interrupt occurs. to configure the endpoints: ? fill the configuration register (eptcfg) with th e endpoint size, direction (in or out), type (ctrl, bulk, it, iso) and the number of banks. ? fill the number of transactions (n b_trans) for isochronous endpoints. note: for control endpoints the direction has no effect. ? verify that the ept_mapd flag is set. this flag is set if the endpoint size and the number of banks are correct compared to the fifo maximum capacity and the maximum number of allowed banks. ? configure control flags of the endpoint and enable it in eptctlenbx according to ?usba endpoint control register? on page 649 . control endpoints can generate interrupts and use only 1 bank. all endpoints (except endpoint 0) can be configur ed either as bulk, interrupt or isochronous. see table 32-1. usba endp oint description . the maximum packet size they can accept corresponds to the maximum endpoint size. note: the endpoint size of 1024 is reserved for isochronous endpoints. the size of the dpram is 4 kb. the dpr is shared by all active endpoints. the memory size required by the active endpoints must not exceed the size of the dpram. control write setup tx data out tx data out tx data stage control read setup stage setup stage setup tx setup tx no data control data in tx data in tx status stage status stage status in tx status out tx status in tx data stage setup stage status stage
599 32015a?avr32?02/07 AT32AP7001 size_dpram = size _ept0 + nb_bank_ept1 x size_ept1 + nb_bank_ept2 x size_ept2 + nb_bank_ept3 x size_ept3 + nb_bank_ept4 x size_ept4 + nb_bank_ept5 x size_ept5 + nb_bank_ept6 x size_ept6 +... (refer to 32.6.17 usba endpoint configuration register ) if a user tries to configure endpoints with a size the sum of which is greater than the dpram, then the ept_mapd is not set. the application has access to the physical block of dpr reserved for the endpoint through a 64 kb logical address space. the physical block of dpr allocated for the endpoint is remapped all along the 64 kb logical address space. the application can write a 64 kb buffer linearly. figure 32-4. logical address space for dpr access: configuration examples of eptctlx ( usba endpoint control register ) for bulk in endpoint type follow below. 64 kb ep0 64 kb ep1 64 kb ep2 dpr logical address 8 to 64 b 8 to1024 b 8 to1024 b 8 to1024 b 64 kb ep3 ... 8 to 64 b 8 to 64 b 8 to 64 b ... ... x banks y banks z banks 8 to1024 b 8 to1024 b 8 to1024 b
600 32015a?avr32?02/07 AT32AP7001 ?with dma ? auto_valid: automatically validate the packet and switch to the next bank. ? ept_enabl: enable endpoint. ? without dma: ? tx_bk_rdy: an interrupt is generated after each transmission. ? ept_enabl: enable endpoint. configuration examples of bulk out endpoint type follow below. ?with dma ? auto_valid: automatically validate the packet and switch to the next bank. ? ept_enabl: enable endpoint. ? without dma ? rx_bk_rdy: an interrupt is sent after a new packet has been stored in the endpoint fifo. ? ept_enabl: enable endpoint.
601 32015a?avr32?02/07 AT32AP7001 32.5.5 dma usb packets of any length may be transferred wh en required by the usba device. these trans- fers always feature sequential addressing. packet data hsb bursts may be locked on a dma buffer basis for drastic overall hsb bus band- width performance boost with pa ged memories. these clock-cycl e consuming memory row (or bank) changes will then likely not occur, or occu r only once instead of dozens times, during a single big usb packet dma transfer in case another hsb master addresses the memory. this means up to 128-word single-cycle unbroken hsb bursts for bulk endpoints and 256-word sin- gle-cycle unbroken bursts for isochronous endpo ints. this maximum burst length is then controlled by the lowest programmed usb endpoint size (ept_size bit in the eptcfgx regis- ter) and dma size (buff_length bit in the dmacontrolx register). the usba device average throughput may be up to near ly 60 mbytes. its in ternal slave average access latency decreases as burst length incr eases due to the 0 wait-state side effect of unchanged endpoi nts. if at least 0 wait-state word burst capability is also pr ovided by the exter- nal dma hsb bus slaves, each of both dm a hsb busses need less than 50% bandwidth allocation for full usba bandwi dth usage at 30 mh z, and less than 25% at 60 mhz. the usba dma channel transfer descriptor is described in ?usba dma channel transfer descriptor? on page 660 figure 32-5. example of dma chained list: 32.5.6 handling transactions with usb v2.0 device peripheral 32.5.6.1 setup transaction the setup packet is valid in the dpr while rx_s etup is set. once rx_setup is cleared by the application, the usba ac cepts the next packets sent over the device endpoint. data buff 1 data buff 2 data buff 3 memory area transfer descriptor next descriptor address dma channel address dma channel control transfer descriptor next descriptor address dma channel address dma channel control transfer descriptor next descriptor address dma channel address dma channel control udphs registers (current transfer descriptor) udphs next descriptor dma channel address dma channel control null
602 32015a?avr32?02/07 AT32AP7001 when a valid setup packet is accepted by the usba: ? the usba device automatically acknowledges the setup packe t (sends an ack response) ? payload data is written in the endpoint ? sets the rx_setup interrupt ? the byte_count field in the ept stax register is updated an endpoint interrupt is generated while rx_setup in the eptstax register is not cleared. this interrupt is carried out to the microcontroller if interrupts are enabled for this endpoint. thus, firmware must detect rx_setup pollin g eptstax or catching an interrupt, read the setup packet in the fifo, then clear the rx_set up bit in the eptclrsta register to acknowl- edge the setup stage. if stall_snt was set to 1, then this bit is automatically reset when a setup token is detected by the device. then, the device still accepts the setup stage. (see section 32.5.6.15 ?stall? on page 613 ). 32.5.6.2 nyet nyet is a high speed only handshake. it is retu rned by a high speed endpoint as part of the ping protocol. high speed devices must support an improved nak mechanism for bulk out and control end- points (except setup stage). this mechanism allows the device to tell the host whether it has sufficient endpoint space for the next out transfe r (see usb 2.0 spec 8.5.1 nak limiting via ping flow control). the nyet/ack response to a high speed bulk out transfer and the ping response are auto- matically handled by hardware in the eptctlx register (except when the user wants to force a nak response by using the nyet_dis bit). if the endpoint responds instead to the out/data transaction with an nyet handshake, this means that the endpoint accepted the data but does not have room for another data payload. the host controller must return to using a ping token until the endpoint indicates it has space available. figure 32-6. nyet example with two endpoint banks t = 0 t = 125 s t = 250 s t = 375 s t = 500 s t = 625 s data 0 ack data 1 nyet ping ack data 0 nyet ping nack ping ack bank 1 bank 0 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 bank 0 bank 1 e f f e f e' f e f f e' f e f e: empty e': begin to empty f: full
603 32015a?avr32?02/07 AT32AP7001 32.5.6.3 data in 32.5.6.4 bulk in or interrupt in data in packets are sent by the device during the data or the status stage of a control transfer or during an (interrupt/bulk/isochronous) in transfer. data buffers are sent packet by packet under the control of the application or under the control of the dma channel. there are three ways for an application to transfer a buffer in several packets over the usb: ? packet by packet (see 32.5.6.5 below) ? 64 kb (see 32.5.6.5 below) ?dma (see 32.5.6.6 below) 32.5.6.5 bulk in or interrupt in: sending a packet under application control (device to host) the application can write one or several banks. a simple algorithm can be used by the application to send packets regardless of the number of banks associated to the endpoint. algorithm description for each packet: ? the application waits for tx_pk_rdy flag to be cleared in the eptstax register before it can perform a write access to the dpr. ? the application writes one usb packet of data in the dpr through the 64 kb endpoint logical memory window. ? the application sets tx_pk_rdy flag in the eptsetstax register. the application is notified that it is possible to write a new packet to the dpr by the tx_pk_rdy interrupt. this interrupt can be enabled or masked by setting the tx_pk_rdy bit in the eptctlenb/eptctldis register. algorithm description to fill several packets: using the previous algorithm, the application is interrupted for each packet. it is possible to reduce the application overhead by writing linearly several banks at the same time. the auto_valid bit in the eptctlx must be set by writing the auto_valid bit in the eptctlenbx register. the auto-valid-bank mechanism allows the transfer of data (in and out) without the interven- tion of the cpu. this means that bank validation (set tx_pk_rdy or clear the rx_bk_rdy bit) is done by hardware. ? the application checks the busy_bank_sta field in the eptstax register. the application must wait that at least one bank is free. ? the application writes a number of bytes inferior to the number of free dpr banks for the endpoint. each time the application writes the last byte of a bank, the tx_pk_rdy signal is automatically set by the usba. ? if the last packet is incomplete (i.e., the last byte of the bank has not been written) the application must set th e tx_pk_rdy bit in the eptsetstax register. the application is notified that all banks are free, so that it is possible to write another burst of packets by the busy_bank interrupt. this interrupt can be enabled or masked by setting the busy_bank flag in the eptctlenb and eptctldis registers.
604 32015a?avr32?02/07 AT32AP7001 this algorithm must not be used for isochronous transfer. in this case, the ping-pong mechanism does not operate. a zero length packet can be sent by setting just the tx_pktrdy flag in the eptsetstax register. 32.5.6.6 bulk in or interrupt in: sending a buffer using dma (device to host) the usba integrates a dma host controller. this dma controller can be used to transfer a buffer from the memory to the dpr or from the dpr to the processor memory under the usba control. the dma can be used for all transfer types except control transfer. example dma configuration: 1. program dmaaddressx with the address of the buffer that should be transfer. 2. enable the interrupt of the dma in ien 3. program dmacontrolx: ? size of buffer to send: size of the buffer to be sent to the host. ? end_b_en: the endpoint can validate the packet (according to the values programmed in the auto_valid and shrt_pckt fields of eptctlx.) (see ?usba endpoint control register? on page 649 and figure 32-11. autovalid with dma ) ? end_buffit: generate an interrup t when the buff_count in dmastatusx reaches 0. ? chann_enb: run and stop at end of buffer the auto-valid-bank mechanism allows the transfer of data (in & out) without the intervention of the cpu. this means that bank validation (s et tx_pk_rdy or clear the rx_bk_rdy bit) is done by hardware. a transfer descriptor can be used. instead of programming the register directly, a descriptor should be programmed and the address of this descriptor is then given to dmanxtdsc to be processed after setting the ldnxt_dsc field (load next descriptor now) in dmacontrolx register. the structure that defines this transfer descriptor must be aligned. each buffer to be transferred must be described by a dma transfer descriptor (see ?usba dma channel transfer descriptor? on page 660 ). transfer descriptors are chained. before executing transfer of the buffer, the usba may fetch a new transfer descriptor from the memory address pointed by the dmanxtdscx register. once the transfer is complete, the transfer status is updated in the dmastatusx register. to chain a new transfer descriptor with the current dma transfer, the dma channel must be stopped. to do so, intdis_dma and tx_bk_rdy may be set in the eptctlenbx register. it is also possible for the application to wait for the completion of all transfers. in this case the ldnxt_dsc field in the last tr ansfer descriptor dmacontrolx register must be set to 0 and chann_enb set to 1. then the application can chain a new transfer descriptor. the intdis_dma can be used to stop the current dma transfer if an enabled interrupt is trig- gered. this can be used to stop dma transfers in case of errors. the application can be notified at the end of any buffer transfer (enb_buffit bit in the dma- controlx register).
605 32015a?avr32?02/07 AT32AP7001 figure 32-7. data in transfer for endpoint with one bank figure 32-8. data in transfer for endpoint with two banks usb bus packets fifo content tx_complt flag (udphs_eptstax) tx_pk_rdy flag (udphs_eptstax) prevous data in tx microcontroller loads data in fifo data is sent on usb bus interrupt pending set by firmware cleared by hardware set by the firmware cleared by hardware interrupt pending cleared by firmware dpr access by firmware dpr access by hardware cleared by firmware payload in fifo set by hardware data in 2 token in nak ack data in 1 token in token in ack data in 1 load in progress data in 2 read by usb device read by udphs device fifo (dpr) bank 0 tx_complt flag (udphs_eptstax) interrupt cleared by firmware virtual tx_pk_rdy bank 1 (udphs_eptstax) ack token in ack set by firmware, data payload written in fifo bank 1 cleared by hardware data payload fully transmitted token in usb bus packets set by hardware set by hardware set by firmware, data payload written in fifo bank 0 written by fifo (dpr) bank1 microcontroller written by microcontroller written by microcontroller microcontroller load data in bank 0 microcontroller load data in bank 1 udphs device send bank 0 microcontroller load data in bank 0 udphs device send bank 1 interrupt pending data in data in cleared by hardware switch to next bank virtual tx_pk_rdy bank 0 (udphs_eptstax)
606 32015a?avr32?02/07 AT32AP7001 figure 32-9. data in followed by status out transfer at the end of a control transfer note : a nak handshake is always generated at the first status stage token. figure 32-10. data out followed by status in transfer note : before proceeding to the status stage, the software should determine that there is no risk of extra data from the host (data stage). if not certain (non-predictable data stage length), then the software should wait for a nak-in interrupt before proceeding to the status stage. this pre- caution should be taken to av oid collision in the fifo. token out data in token in ack ack data out (zlp) rx_bk_rdy (udphs_eptstax) tx_complt (udphs_eptstax) set by hardware set by hardware usb bus packets cleared by firmware cleared by firmware device sends a status out to host device sends the last data payload to host interrupt pending token out ack data out (zlp) token in ack data out token out ack data in usb bus packets rx_bk_rdy (udphs_eptstax) cleared by firmware set by hardware clear by hardware tx_pk_rdy (udphs_eptstax) set by firmware host sends the last data payload to the device device sends a status in to the host interrupt pending
607 32015a?avr32?02/07 AT32AP7001 figure 32-11. autovalid with dma note: in the illustration above autovalid validates a bank as full, although this might not be the case, in order to continue pr ocessing data and to send to dma. 32.5.6.7 isochronous in isochronous-in is used to transmit a stream of data whose timing is implied by the delivery rate. isochronous transfer provides periodic, continuous communication between host and device. it guarantees bandwidth and low latencies appropriate for telephony, audio, video, etc. if the endpoint is not available (tx_pk_rdy = 0), then the device does not answer to the host. an err_fl_iso interrupt is generated in the eptstax register and once enabled, then sent to the cpu. the stall_snt command bit is not used for an iso-in endpoint. bank 0 bank 1 bank 0 bank (usb) write write bank 0 write bank 1 write bank 0 bank 0 bank (system) bank 1 bank 0 bank 1 virtual tx_pk_rdy bank 0 virtual tx_pk_rdy bank 1 tx_pk_rdy (virtual 0 & virtual 1) bank 0 is full bank 1 is full bank 0 is full in data 0 in data 1 in data 0 bank 1 bank 1 bank 0
608 32015a?avr32?02/07 AT32AP7001 32.5.6.8 high bandwidth isochronous endpoint handling: in example for high bandwidth isochronous endpoints, the dma can be programmed with the number of transactions (buff_length field in dmacontrolx) and the system should provide the required number of packets per microfra me, otherwise, the host will notice a sequencing problem. a response should be made to the first token in recognized inside a microframe under the fol- lowing conditions: ? if at least one bank has been validated, the correct datax corresponding to the programmed number of transactions per microframe (nb_trans) should be answered. in case of a subsequent missed or co rrupted token in inside the microf rame, the usba core available data bank(s) that should normally have been transmitted during that microframe shall be flushed at its end. if this flush occurs, an error condit ion is flagged (err_flush is set in eptstax). ? if no bank is validated yet, the default data0 zlp is answered and underflow is flagged (err_fl_iso is set in eptstax). then, no data bank is flushed at microframe end. ? if no data bank has been validated at the time when a response should be made for the second transaction of nb_trans = 3 transactions microframe, a data1 zlp is answered and underflow is flagged (err_fl_iso is set in eptstax). if and only if remaining untransmitted banks for that microframe are available at its end, they are flushed and an error condition is flagged (err_flush is set in eptstax). ? if no data bank has been validated at the time when a response should be made for the last programmed transaction of a microframe, a data0 zlp is answered and underflow is flagged (err_fl_iso is set in eptstax). if and only if the remaining untransmitted data bank for that microframe is available at its end, it is flushed and an error condition is flagged (err_flush is set in eptstax). ? if at the end of a microframe no valid token in has been recognized, no data bank is flushed and no error condition is reported. at the end of a microframe in which at least one data bank has been transmitted, if less than nb_trans banks have been validated for that microframe, an error condition is flagged (err_trans is set in eptstax). cases of error (in eptstax) ? err_fl_iso: there was no data to transmit inside a microframe, so a zlp is answered by default. ? err_flush: at least one packet has been sent inside the microframe, but the number of token in received is lesser than the number of transactions actually validated (tx_bk_rdy) and likewise with the nb_trans programmed. ? err_trans: at least one packet has been sent inside the microframe, but the number of token in received is lesser than the number of programmed nb_trans transactions and the packets not requested were not validated. ? err_fl_iso + err_flush: at least one packet has been sent inside the microframe, but the data has not been validated in time to answer one of the following token in. ? err_fl_iso + err_trans: at least one packet has been sent inside the microframe, but the data has not been validated in time to answer one of the following token in and the data can be discarded at the microframe end.
609 32015a?avr32?02/07 AT32AP7001 ? err_flush + err_trans: the first token in has been answered and it was the only one received, a second bank has been validated but not the third, whereas nb_trans was waiting for three transactions. ? err_fl_iso + err_flush + err_trans: the first token in has been treated, the data for the second token in was not available in time, but the second bank has been validated before the end of the microframe. the third bank has not been validated, but three transactions have been set in nb_trans. 32.5.6.9 data out 32.5.6.10 bulk out or interrupt out like data in, data out packets are sent by the host during the data or the status stage of con- trol transfer or during an interrupt/bulk/isochronous out transfer. data buffers are sent packet by packet under the control of the application or under the control of the dma channel. 32.5.6.11 bulk out or interrupt out: receiving a packet under application control (host to device) algorithm description for each packet: ? the application enables an interrupt on rx_bk_rdy. ? when an interrupt on rx_bk_rdy is received, the application knows that eptstax register byte_count bytes have been received. ? the application reads the byte_count bytes from the endpoint. ? the application clears rx_bk_rdy. note: if the application does not know the size of the transfer, it may not be a good option to use auto_valid. because if a zero-length-packet is received, the rx_bk_rdy is automatically cleared by the auto_valid hardwa re and if the endpoint interrupt is triggered, the software will not find its originating flag when reading the eptstax register. algorithm to fill several packets: ? the application enables the interrupts of busy_bank and auto_valid. ? when a busy_bank interrupt is received, the application knows that all banks available for the endpoint have be en filled. thus, the application can read all banks available. if the application doesn?t know the size of t he receive buffer, instead of using the busy_bank interrupt, the application must use rx_bk_rdy. 32.5.6.12 bulk out or interrupt out: sending a buffer using dma (host to device) to use the dma setting, the auto_valid field is mandatory. see 32.5.6.6 bulk in or interrupt in: sending a buffer using dma (device to host) for more information. dma configuration example: 1. first program dmaaddressx with the address of the buffer that should be transferred. 2. enable the interrupt of the dma in ien 3. program the dma channe lx control register: ? size of buffer to be sent. ? end_b_en: can be used for out packet truncation (discarding of unbuffered packet data) at the end of dma buffer.
610 32015a?avr32?02/07 AT32AP7001 ? end_buffit: generate an interrup t when buff_count in the dmastatusx register reaches 0. ? end_tr_en: end of transfer enable, the usba device can put an end to the current dma transfer, in case of a short packet. ? end_tr_it: end of transfer interrupt enable, an interrupt is sent after the last usb packet has been transferred by the dma, if the usb transfer ended with a short packet. (beneficial when the receive size is unknown.) ? chann_enb: run and stop at end of buffer. for out transfer, the bank will be automatical ly cleared by hardware when the application has read all the bytes in the bank (the bank is empty). note: when a zero-length-packet is received, rx_bk_rdy bit in eptstax is cleared automat- ically by auto_valid, and the application knows of the end of buffer by the presence of the end_tr_it. note: if the host sends a zero-length packet, and the endpoint is free, then the device sends an ack. no data is written in the endpoint, the rx_by_rdy interrupt is generated, and the byte_count field in eptstax is null. figure 32-12. data out transfer for endpoint with one bank ack token out nak token out ack token out data out 1 usb bus packets rx_bk_rdy set by hardware cleared by firmware, data payload written in fifo fifo (dpr) content written by udphs device microcontroller read data out 1 data out 1 data out 2 host resends the next data payload microcontroller transfers data host sends data payload data out 2 data out 2 host sends the next data payload written by udphs device (udphs_eptstax) interrupt pending
611 32015a?avr32?02/07 AT32AP7001 figure 32-13. data out transfer for an endpoint with two banks 32.5.6.13 high bandwidth isochronous endpoint out figure 32-14. bank management, example of three transactions per microframe usb 2.0 supports individual high speed isochronous endpoints that require data rates up to 192 mb/s (24 mb/s): 3x1024 data bytes per microframe. to support such a rate, two or three banks ma y be used to buffer the three consecutive data packets. the microcontroller (or the dma) should be able to empty the banks very rapidly (at least 24 mb/s on average). nb_trans field in eptcfgx register = number of transactions per microframe. if nb_trans > 1 then it is high bandwidth. token out ack data out 3 token out data out 2 token out data out 1 data out 1 data out 2 data out 2 ack cleared by firmware usb bus packets virtual rx_bk_rdy bank 0 virtual rx_bk_rdy bank 1 set by hardware data payload written in fifo endpoint bank 1 fifo (dpr) bank 0 bank 1 write by udphs device write in progress read by microcontroller read by microcontroller set by hardware, data payload written in fifo endpoint bank 0 host sends first data payload microcontroller reads data 1 in bank 0, host sends second data payload microcontroller reads data 2 in bank 1, host sends third data payload cleared by firmware write by hardware fifo (dpr) (udphs_eptstax) interrupt pending interrupt pending rx_bk_rdy = (virtual bank 0 | virtual bank 1) data out 1 data out 3 m data 0 m data 0 m data 1 data 2 data 2 m data 1 t = 0 t = 52.5 s (40% of 125 s) rx_bk_rdy t = 125 s rx_bk_rdy usb line read bank 3 read bank 2 read bank 1 read bank 1 usb bus transactions microcontroller fifo (dpr) access
612 32015a?avr32?02/07 AT32AP7001 example: ? if nb_trans = 3, the sequence should be either ?mdata0 ? mdata0/data1 ? mdata0/data1/data2 ? if nb_trans = 2, the sequence should be either ?mdata0 ? mdata0/data1 ? if nb_trans = 1, the sequence should be ? data0 32.5.6.14 isochronous endpoint handling: out example the user can ascertain the bank status (free or busy), and the toggle sequencing of the data packet for each bank with the eptstax regi ster in the three bit fields as follows: ? togglesq_sta: pid of the data stored in the current bank ? current_bank: number of the bank currently being accessed by the microcontroller. ? busy_bank_sta: number of busy bank this is particularly useful in case of a missing data packet. if the inter-packet delay between the out token and the data is greater than the usb standard, then the iso-out transaction is ignored. (payload data is not written, no interrupt is generated to the cpu.) if there is a data crc (cyclic redundancy check) error, the payload is, none the less, written in the endpoint. the err_criso flag is set in eptstax register. if the endpoint is already full, the packet is not written in the dpram. the err_fl_iso flag is set in eptstax. if the payload data is greater than the maximum size of the endpoint, then the err_ovflw flag is set. it is the task of the cpu to manage this error. the data packet is written in the endpoint (except the extra data). if the host sends a zero length packet, and the endpoint is free, no data is written in the end- point, the rx_bk_rdy flag is set, and the byte_ count field in eptstax register is null. the frcestall command bit is unused for an isochonous endpoint. otherwise, payload data is written in the endpoint, the rx_bk_rdy interrupt is generated and the byte_count in eptstax register is updated.
613 32015a?avr32?02/07 AT32AP7001 32.5.6.15 stall stall is returned by a function in response to an in token or after the data phase of an out or in response to a ping transaction. stall indicates that a function is unable to transmit or receive data, or that a control pipe request is not supported. ?out to stall an endpoint, set the frcestall bit in eptsetstax register and after the stall_snt flag has been set, set the toggle_seg bit in the eptclrstax register. ?in set the frcestall bit in eptsetstax register. figure 32-15. stall handshake data out transfer figure 32-16. stall handshake data in transfer token out stall pid data out usb bus packets cleared by firmware set by firmware frcestall stall_snt set by hardware interrupt pending cleared by firmware token in stall pid usb bus packets cleared by firmware set by firmware frcestall stall_snt set by hardware cleared by firmware interrupt pending
614 32015a?avr32?02/07 AT32AP7001 32.5.7 speed identification the high speed reset is managed by the hardware. at the connection, the host makes a reset which could be a classic reset (full speed) or a high speed reset. at the end of the re set process (full or high), the endreset interrupt is generated. then the cpu should read the speed bit in intstax to ascertain the speed mode of the device. 32.5.8 usb v2.0 high speed global interrupt interrupts are defined in section 32.6.3 ?usba interr upt enable register? (ien) and in section 32.6.4 ?usba interrup t status register? (intsta). 32.5.9 endpoint interrupts interrupts are enabled in ien (see section 32.6.3 ?usba inte rrupt enable register? ) and individ- ually masked in eptctlenbx (see section 32.6.18 ?usba endpoint control enable register? ). table 32-5. endpoint interrupt source masks shrt_pckt short packet interrupt busy_bank busy bank interrupt nak_out nakout interrupt nak_in/err_flush nakin/error flush interrupt stall_snt/err_criso/err_nb_tra stall sent/crc e rror/number of transaction error interrupt rx_setup/err_fl_iso received setup/error flow interrupt tx_pk_rd /err_trans tx packet read/transaction error interrupt tx_complt transmitted in da ta complete interrupt rx_bk_rdy received out data interrupt err_ovflw overflow error interrupt mdata_rx mdata interrupt datax_rx datax interrupt
615 32015a?avr32?02/07 AT32AP7001 figure 32-17. usba interrupt control interface det_suspd micro_sof ien_sof endreset wake_up endofrsm upstr_res usb global it sources ept0 it sources busy_bank nak_out (udphs_eptctlenbx) nak_in/err_flush stall_snt/err_criso/err_nb_tra rx_setup/err_fl_iso tx_bk_rdy/err_trans tx_complt rx_bk_rdy err_ovflw mdata_rx datax_rx (udphs_ien) ept1-6 it sources global it mask global it sources ep mask ep sources (udphs_ien) ept_int_0 ep mask ep sources (udphs_ien) ept_int_x (udphs_eptctlx) int_dis_dma dma ch x (udphs_dmacontrolx) en_buffit end_tr_it desc_ld_it mask mask mask (udphs_ien) dma_int_x shrt_pckt husb2dev interrupt disable dma channelx request
616 32015a?avr32?02/07 AT32AP7001 32.5.10 power modes 32.5.10.1 controllin g device states a usb device has several possible states. refer to chapter 9 (usb device framework) of the universal serial bus specification, rev 2.0. figure 32-18. usbadevice state diagram movement from one state to another depends on the usb bus state or on standard requests sent through control transactions via the default endpoint (endpoint 0). after a period of bus inactivity, the us b device enters suspend mode. accepting sus- pend/resume requests from the usb host is mandatory. constraints in suspend mode are very strict for bus-powered applications; devices may not consume more than 500 a on the usb bus. while in suspend mode, the host may wake up a de vice by sending a resume signal (bus activ- ity) or a usb device may send a wake-up request to the host, e.g., waking up a pc by moving a usb mouse. attached suspended suspended suspended suspended hub reset or deconfigured hub configured bus inactive bus activity bus inactive bus activity bus inactive bus activity bus inactive bus activity reset reset address assigned device deconfigured device configured powered default address configured power interruption
617 32015a?avr32?02/07 AT32AP7001 the wake-up feature is not mandatory for all devices and must be negotiated with the host. 32.5.10.2 from powered state to default state (reset) after its connection to a usb host, the usb device waits for an end-of-bus reset. the unmasked flag endreset is set in the ien regist er and an interr upt is triggered. once the endreset interrupt has be en triggered, the devi ce enters default st ate. in this state, the usba software must: ? enable the default endpoint, setting the ept_enabl flag in the eptctlenb[0] register and, optionally, enabling the interrupt for endpoint 0 by writing 1 in ept_int_0 of the ien register. the enumeration then begins by a control transfer. ? configure the interrupt mask register which has been reset by the usb reset detection ? enable the transceiver. in this state, the en_usba bit in ctrl register must be enabled. 32.5.10.3 from default state to address state (address assigned) after a set address standard device request, the usb host peripheral enters the address state. warning : before the device enters address state, it must achieve the status in transaction of the control transfer, i.e., the usba device sets it s new address once the tx_complt flag in the eptctl[0] register has been received and cleared. to move to address state, the driver software sets the dev_addr field and the faddr_en flag in the ctrl register. 32.5.10.4 from address state to configured state (device configured) once a valid set configuration standard request has been received and acknowledged, the device enables endpoints corresponding to the current configuration. this is done by setting the bk_number, ept_type, ept_dir and ept_size fi elds in the eptcfgx registers and enabling them by setting the ep t_enabl flag in the eptctlenbx registers, and, optionally, enabling corresponding interrupts in the ien register. 32.5.10.5 entering suspend state (bus activity) when a suspend (no bus activity on the usb bus ) is detected, the det_suspd signal in the intsta register is set. this triggers an interrupt if the corresponding bit is set in the ien register. this flag is cleared by writing to the clrint register. then the device enters suspend mode. in this state bus powered devices must drain less than 500 a from the 5v vbus. as an exam- ple, the microcontroller switches to slow clock, disables the pl l and main osc illator, and goes into idle mode. it may also switch off other devices on the board. the usbausba device peripheral clocks can be switched off. resume ev ent is asynchronously detected. 32.5.10.6 receiving a host resume in suspend mode, a resume event on the usb bus line is detected asynchronously, transceiver and clocks disabled (however the pull-up should not be removed).
618 32015a?avr32?02/07 AT32AP7001 once the resume is detected on th e bus, the signal wake_up in the intsta is set. it may gen- erate an interrupt if the corresponding bit in the ien register is set. this interrupt may be used to wake-up the core , enable pll and main oscilla tors and configure clocks. 32.5.10.7 sending an external resume in suspend state it is possible to wake-up the host by sending an external resume. the device waits at least 5 ms after being entered in suspend state before sending an external resume. the device must force a k state from 1 to 15 ms to resume the host. 32.5.11 test mode a device must support the test_mode feature when in the default, address or configured high speed device states. test_mode can be: ?test_j ?test_k ? test_packet ? test_seo_nak (see section 32.6.11 ?usba test register? on page 635 for definitions of each test mode.) const char test_packet_buffer[] = { // jkjkjkjk * 9 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // jjkkjjkk * 8 0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa, // jjkkjjkk * 8 0xee,0xee,0xee,0xee,0xee,0xee,0xee,0xee, // jjjjjjjkkkkkkk * 8 0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, // jjjjjjjk * 8 0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd, // {jkkkkkkk * 10}, jk 0xfc,0x7e,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0x7e };
619 32015a?avr32?02/07 AT32AP7001 32.6 usb high speed device (usba) user interface table 32-6. register mapping offset register name access reset 0x00 usba control register ctrl read/write 0x0000_0200 0x04 usba frame number register fnum read 0x0000_0000 0x08 - 0x0c reserved ? ? ? 0x10 usba interrupt enable register ien read/write 0x0000_0010 0x14 usba interrupt status register intsta read 0x0000_0000 0x18 usba clear interrupt register clrint write ? 0x1c usba endpoints reset register eptrst write ? 0x20 - 0xcc reserved ? ? ? 0xd0 usba test sof counter register tstsofcnt read/write 0x0000_0000 0xd4 usba test a counter register tstcnta read/write 0x0000_0000 0xd8 usba test b counter register tstcntb read/write 0x0000_0000 0xdc usba test mode register tstmodereg read/write 0x0000_0000 0xe0 usba test register tst read/write 0x0000_0000 0xe4 - 0xe8 reserved ? ? ? 0xec usba paddrsize register ippaddrsize read 0x0000_4000 0xf0 usba name1 register ipname1 read 0x4855_5342 0xf4 usba name2 register ipname2 read 0x3244_4556 0xf8 usba features register ipfeatures read 0xfc usba ip version register ipversion read 0x100 usba endpoint configuration register eptcfgx read/write 0x0000_0000 0x104 usba endpoint control enable register eptctlenbx write ? 0x108 usba endpoint control disable register eptctldisx write ? 0x10c usba endpoint control register eptctlx read 0x0000_0000 (1) 0x110 reserved ? ? ? 0x114 usba endpoint set status register eptsetstax write ? 0x118 usba endpoint clear status register eptclrstax write ? 0x11c usba endpoint status register eptsta read 0x0000_0040 0x120 - 0x1fc endpoints 1 to 7 0x200 - 0x2fc endpoints 8 to 15 0x200 - 0x30c reserved ? ? ? 0x300 - 0x30c reserved ? ? ? 0x310 usba dma next descriptor address register dmanxtdscx read/write 0x0000_0000 0x314 usba dma channelx address register dmaaddressx read /write 0x0000_0000
620 32015a?avr32?02/07 AT32AP7001 note: 1. the reset value for eptctl0 is 0x0000_0001 0x318 usba dma channelx control register dmacontrolx read/write 0x0000_0000 0x31c usba dma channelx status register dmastatusx read/write 0x0000_0000 0x320 - 0x37c dma channel 2 to 7 table 32-6. register mapping (continued) offset register name access reset
621 32015a?avr32?02/07 AT32AP7001 32.6.1 usba control register name: ctrl access type: read/write ? dev_addr: usba address read: this field contains the default address (0) after power-up or usba bus reset. write: this field is written with the value set by a set_address request received by the device firmware. ? faddr_en: function address enable read: 0 = device is not in address state. 1 = device is in address state. write: 0 = only the default function address is used (0). 1 = this bit is set by the device firm ware after a successful status phase of a set_address transaction. when set, the only address accepted by the usba controller is the one stored in the usba ad dress field. it will not be cleared afterwards by the device firmware. it is cleared by hardware on hardware reset, or when usba bus reset is received (see above). ? en_usba: usba enable read: 0 = usba is disabled. 1 = usba is enabled. write: 0 = disable and reset the usba contro ller, disable the usba transceiver. 1 = enables the usba controller. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????rewakeupdetachen_usba 76543210 faddr_en dev_addr
622 32015a?avr32?02/07 AT32AP7001 ? detach: detach command read: 0 = usba is attached. 1 = usba is detached, utmi transceiver is suspended. write: 0 = pull up the dp line (attach command). 1 = simulate a detach on the usba line and force the ut mi transceiver into suspe nd state (suspend m = 0). ? rewakeup : send remote wake up read: 0 = remote wake up is disabled. 1 = remote wake up is enabled. write: 0 = no effect. 1 = force an external interrupt on the usba controller for remote wake up purposes. an upstream resume is sent onl y after the usba bus has been in su spend state for at least 5 ms. this bit is automatically cleared by hardware at the end of the upstream resume.
623 32015a?avr32?02/07 AT32AP7001 32.6.2 usba frame number register name: fnum access type: read ? micro_frame_num: microframe number number of the received microframe (0 to 7) in one frame.this field is reset at the beginning of each new frame (1 ms). one microframe is received each 125 microseconds (1 ms/8). ? frame_number: frame number as defined in the packet field formats this field is provided in the last received sof packet (see int_sof in the usba interrupt status register ). ? fnum_err: frame number crc error this bit is set by hardware when a corrupted frame number in start of frame packet (or micro sof) is received. this bit and the int_sof (or micro_sof) interrupt are updated at the same time. 31 30 29 28 27 26 25 24 fnum_err??????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ? ? frame_number 76543210 frame_number micro_frame_num
624 32015a?avr32?02/07 AT32AP7001 32.6.3 usba interrupt enable register name: ien access type: read/write ? det_suspd: suspend interrupt enable read: 0 = suspend interrupt is disabled. 1 = suspend interrupt is enabled. write 0 = disable suspend interrupt. 1 = enable suspend interrupt. ? micro_sof: micro-sof interrupt enable read: 0 = micro-sof interrupt is disabled. 1 = micro-sof interrupt is enabled. write 0 = disable micro-sof interrupt. 1 = enable micro-sof interrupt. ? int_sof: sof interrupt enable read: 0 = sof interrupt is disabled. 1 = sof interrupt is enabled. write 0 = disable sof interrupt. 1 = enable sof interrupt. 31 30 29 28 27 26 25 24 dma_int_6 dma_int_5 dma_int_4 d ma_int_3 dma_int_2 dma_int_1 ? 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 ept_int_7 ept_int_6 ept_int_5 ept_int_4 ept_int_3 ept_int_2 ept_int_1 ept_int_0 76543210 upstr_res endofrsm wake_up endreset int_sof micro_sof det_suspd ?
625 32015a?avr32?02/07 AT32AP7001 ? endreset: end of reset interrupt enable read: 0 = end of reset interrupt is disabled. 1 = end of reset interrupt is enabled. write 0 = disable end of reset interrupt. 1 = enable end of reset interrupt. ? wake_up: wake up cpu interrupt enable read: 0 = wake up cpu interrupt is disabled. 1 = wake up cpu interrupt is enabled. write 0 = disable wake up cpu interrupt. 1 = enable wake up cpu interrupt. ? endofrsm: end of resume interrupt enable read: 0 = resume interrupt is disabled. 1 = resume interrupt is enabled. write 0 = disable resume interrupt. 1 = enable resume interrupt. ? upstr_res: upstream resume interrupt enable read: 0 = upstream resume interrupt is disabled. 1 = upstream resume interrupt is enabled. write 0 = disable upstream resume interrupt. 1 = enable upstream resume interrupt. ? ept_int_x: endpointx interrupt enable read: 0 = the interrupts for this endpoint are disabled. 1 = the interrupts for this endpoint are enabled. write 0 = disable the interrupts for this endpoint. 1 = enable the interrupts for this endpoint.
626 32015a?avr32?02/07 AT32AP7001 ? dma_int_x: dma channelx interrupt enable read: 0 = the interrupts for this channel are disabled. 1 = the interrupts for this channel are enabled. write 0 = disable the interrupts for this channel. 1 = enable the interrupts for this channel.
627 32015a?avr32?02/07 AT32AP7001 32.6.4 usba interrupt status register name: intsta access type: read-only ? speed: speed status 0 = reset by hardware when the hardware is in full speed mode. 1 = set by hardware when the hardware is in high speed mode ? det_suspd: suspend interrupt 0 = cleared by setting the det_suspd bit in clrint register 1 = set by hardware when a usba suspend (i dle bus for three frame periods, a j stat e for 3 ms) is detected. this triggers a usba interrupt w hen the det_suspd bit is set in ien register. ? micro_sof: micro start of frame interrupt 0 = cleared by setting the micro_sof bit in clrint register. 1 = set by hardware when an usba micro st art of frame pid (sof) has been detected (e very 125 us) or synthesized by the macro. this triggers a usba interrupt when the micro_sof bit is set in ie n. in case of de tected sof, the micro_frame_num field in fnum register is incremented and the frame_number field doesn?t change. note: the micro start of frame interrupt (micro_sof), and the star t of frame interrupt (int_sof) are not generated at the same time. ? int_sof: start of frame interrupt 0 = cleared by setting the int_sof bit in clrint. 1 = set by hardware when an usba start of frame pid (sof) has been detected (every 1 ms) or synthesized by the macro. this triggers a usba interrupt when the int_sof bit is set in ien register. in case of detected sof, in high speed mode, the micro_frame_number field is cleared in fn um register and the frame_number field is updated. ? endreset: end of reset interrupt 0 = cleared by setting th e endreset bit in clrint. 1 = set by hardware when an end of rese t has been detected by the usba controller. this trig gers a usba interrupt when the endreset bit is set in ien. 31 30 29 28 27 26 25 24 dma_int_6 dma_int_5 dma_int_4 dma_int_3 dma_int_2 dma_int_1 ? 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 ept_int_7 ept_int_6 ept_int _5 ept_int_4 ept_int_3 ept_i nt_2 ept_int_1 ept_int_0 76543210 upstr_res endofrsm wake_up endreset int_sof micro_sof det_suspd speed
628 32015a?avr32?02/07 AT32AP7001 ? wake_up: wake up cpu interrupt 0 = cleared by setting the wake_up bit in clrint. 1 = set by hardware when the usba controller is in suspen d state and is re-activated by a filtered non-idle signal from the usba line (not by an upstre am resume). this trig gers a usba interrupt when the wake_ up bit is set in ien register. when receiving this interrupt, the user has to enable the device controller clock prior to operation. note: this interrupt is generated even if the device controller clock is disabled. ? endofrsm: end of resume interrupt 0 = cleared by setting the endofrsm bit in clrint. 1 = set by hardware when the usba controller detects a good end of resume signal initiated by the host. this triggers a usba interrupt when the endofrsm bit is set in ien. ? upstr_res: upstream resume interrupt 0 = cleared by setting the upstr_res bit in clrint. 1 = set by hardware when the usba contro ller is sending a resume signal called ? upstream resume?. th is triggers a usba interrupt when the upstr_res bit is set in ien. ? ept_int_x: endpointx interrupt 0 = reset when the eptstax interrupt source is cleared. 1 = set by hardware when an interrupt is triggered by the eptst ax register and this endpoint interrupt is enabled by the ept_int_x bit in ien. ? dma_int_x: dma channelx interrupt 0 = reset when the dmastatusx interrupt source is cleared. 1 = set by hardware when an interrupt is triggered by the dma channelx and this endpoint interrupt is enabled by the dma_int_x bit in ien.
629 32015a?avr32?02/07 AT32AP7001 32.6.5 usba clear interrupt register name: clrint access type: write only ? det_suspd: suspend interrupt clear 0 = no effect. 1 = clear the det_suspd bit in intsta. ? micro_sof: micro start of frame interrupt clear 0 = no effect. 1 = clear the micro_sof bit in intsta. ? int_sof: start of frame interrupt clear 0 = no effect. 1 = clear the int_sof bit in intsta. ? endreset: end of re set interrupt clear 0 = no effect. 1 = clear the endreset bit in intsta. ? wake_up: wake up cpu interrupt clear 0 = no effect. 1 = clear the wake_up bit in intsta. ? endofrsm: end of resume interrupt clear 0 = no effect. 1 = clear the endofrsm bit in intsta. ? upstr_res: upstream resume interrupt clear 0 = no effect. 1 = clear the upstr_res bit in intsta. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 upstr_res endofrsm wake_up endreset int_sof micro_sof det_suspd ?
630 32015a?avr32?02/07 AT32AP7001 32.6.6 usba endpoints reset register name: eptrst access type: write only ? rst_ept_x: endpointx reset 0 = no effect. 1 = reset the endpointx state. setting this bit clears the endpoint status eptst ax register, except for the togglesq_sta field. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 76543210 rst_ept_7 rst_ept_6 rst_ept _5 rst_ept_4 rst_ept_3 rst_ ept_2 rst_ept_1 rst_ept_0
631 32015a?avr32?02/07 AT32AP7001 32.6.7 usba test sof counter register name: tstsofcnt access type: read/write ? sofcntmax: sof counter max value ? sofctload: sof counter load 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 sofctload sofcntmax
632 32015a?avr32?02/07 AT32AP7001 32.6.8 usba test a counter register name: tstcnta access type: read/write ? cntaload: a counter load ? cntamax: a counter max value 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 cntaload cntamax 76543210 cntamax
633 32015a?avr32?02/07 AT32AP7001 32.6.9 usba test b counter register name: tstcntb access type: read/write ? cntbload: b counter load ? cntbmax: b counter max value 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 cntbload ? cntbmax
634 32015a?avr32?02/07 AT32AP7001 32.6.10 usba test mode register name: tstmodereg access type: read/write ? tstmode: usba core testmodereg 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?? tstmode
635 32015a?avr32?02/07 AT32AP7001 32.6.11 usba test register name: tst access type: read/write ? speed_cfg: speed configuration read/write: speed configuration: ? tst_j: test j mode read and write: 0 = no effect. 1 = set to send the j state on the usba line. this enables the testing of the high output drive level on the d+ line. ? tst_k: test k mode read and write: 0 = no effect. 1 = set to send the k state on the usba line. this enables the test ing of the high output dr ive level on the d- line. ? tst_pkt: test packet mode read and write: 0 = no effect. 1 = set to repetitively transmit the packet stored in the current bank. this enables the testing of rise and fall times, eye pa t- terns, jitter, and any other dynamic waveform specifications. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? opmode2 tst_pkt tst_k tst_j speed_cfg 00 normal mode: the macro is in full speed mode, ready to make a high speed identification, if the host supports it and then to automatically switch to high speed mode 01 reserved 10 force high speed: set this value to force the hardware to work in high speed mode. only for debug or test purpose. 11 force full speed: set this value to force the hardware to work only in full speed mode. in this configuration, the macro will not respond to a high speed reset handshake
636 32015a?avr32?02/07 AT32AP7001 ? opmode2: opmode2 read and write: 0 = no effect. 1 = set to force the opmode signal (utmi interface) to ?10?, to disable the bit-stuffing and the nrzi encoding. note: for the test mode, test_se0_nak (see universal serial bus specification, revision 2.0: 7.1.20, test mode sup- port). force the device in high speed m ode, and configure a bulk-ty pe endpoint. do not fill this endpoint for sending nak to the host. upon command, a port?s transceiver must enter the high speed receive mode and remain in that mode until the exit action is taken. this enables the testing of output impedance, low level output voltage and loading characteristics. in addition, while in this mode, upstream facing ports (and only upstream facing ports) must respond to any in token packet with a nak handshake (only if the packet crc is dete rmined to be correct) within the norm al allowed device response time. this enables testing of the device squelch level circuitry and, additi onally, provides a general purpose stimulus/response test for basic functional testing.
637 32015a?avr32?02/07 AT32AP7001 32.6.12 usba paddrsize register name: ippaddrsize access type: read-only ? ip_paddrsize 2^paddr_size pb address bus aperture of the usba 31 30 29 28 27 26 25 24 ip_paddrsize 23 22 21 20 19 18 17 16 ip_paddrsize 15 14 13 12 11 10 9 8 ip_paddrsize 76543210 ip_paddrsize
638 32015a?avr32?02/07 AT32AP7001 32.6.13 usba na me1 register name: ipname1 access type: read-only ? ip_name1 ascii string ?husb? 31 30 29 28 27 26 25 24 ip_name1 23 22 21 20 19 18 17 16 ip_name1 15 14 13 12 11 10 9 8 ip_name1 76543210 ip_name1
639 32015a?avr32?02/07 AT32AP7001 32.6.14 usba na me2 register name: ipname2 access type: read-only ? ip_name2 ascii string ?2dev? 31 30 29 28 27 26 25 24 ip_name2 23 22 21 20 19 18 17 16 ip_name2 15 14 13 12 11 10 9 8 ip_name2 76543210 ip_name2
640 32015a?avr32?02/07 AT32AP7001 32.6.15 usba features register name: ipfeatures access type: read-only ? ept_nbr_max: max number of endpoints give the max number of endpoints. 0 = if 16 endpoints are hardware implemented. 1 = if 1 endpoint is hardware implemented. 2 = if 2 endpoints are hardware implemented. ... 15 = if 15 endpoints are hardware implemented. ? dma_channel_nbr: number of dma channels give the number of dma channels. 1 = if 1 dma channel is hardware implemented. 2 = if 2 dma channels are hardware implemented. ... 7 = if 7 dma channels are hardware implemented. ? dma_b_siz: dma buffer size 0 = if the dma buffer size is 16 bits. 1 = if the dma buffer size is 24 bits. ? dma_fifo_word_depth: dma fifo depth in words 0 = if fifo is 16 words deep. 1 = if fifo is 1 word deep. 2 = if fifo is 2 words deep. ... 15 = if fifo is 15 words deep. 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 iso_ept_7 iso_ept_6 iso_ept_5 iso_ept_4 is o_ept_3 iso_ept_2 iso_ept_1 datab16_8 15 14 13 12 11 10 9 8 bw_dpram fifo_max_size dma_fifo_word_depth 76543210 dma_b_siz dma_channel_nbr ept_nbr_max
641 32015a?avr32?02/07 AT32AP7001 ? fifo_max_size: dpram size 0 = if dpram is 128 bytes deep. 1 = if dpram is 256 bytes deep. 2 = if dpram is 512 bytes deep. 3 = if dpram is 1024 bytes deep. 4 = if dpram is 2048 bytes deep. 5 = if dpram is 4096 bytes deep. 6 = if dpram is 8192 bytes deep. 7 = if dpram is 16384 bytes deep. ? bw_dpram: dpram by te write capability 0 = if dpram write data shadow logic is implemented. 1 = if dpram is byte write capable. ? datab16_8: utmi databus16_8 0 = if the utmi uses an 8-bit parallel data interface (60 mhz, unidirectional). 1 = if the utmi uses a 16-bit parallel data interface (30 mhz, bidirectional). ? iso_ept_x: endpointx high bandwidth isochronous capability 0 = if the endpoint does not have isochronous high bandwidth capability. 1 = if the endpoint has isochronous high bandwidth capability.
642 32015a?avr32?02/07 AT32AP7001 32.6.16 usba ip version register name: ipversion access type: read-only ? version_num: ip version give the ip version. ? metal_fix_num: number of metal fixes give the number of metal fixes. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ????? metal_fix_num 15 14 13 12 11 10 9 8 version_num 76543210 version_num
643 32015a?avr32?02/07 AT32AP7001 32.6.17 usba endpoint configuration register name: eptcfgx access type: read/write ? ept_size: endpoint size read and write: set this field according to the endpoint size in bytes (see section 32.5.4 ?endpoint configuration? ). endpoint size note: 1. 1024 bytes is only for isochronous endpoint. ? ept_dir: endpoint direction read and write: 0 = clear this bit to configure out direction for bulk, interrupt and isochronous endpoints. 1 = set this bit to configure in direction for bulk, interrupt and isochronous endpoints. for control endpoints this bit has no effect and should be left at zero. ? ept_type: endpoint type read and write: set this field according to the endpoint type (see section 32.5.4 ?endpoint configuration? ). (endpoint 0 should always be configured as control) 31 30 29 28 27 26 25 24 ept_mapd??????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????? nb_trans 76543210 bk_number ept_type ept_dir ept_size 000 8 bytes 001 16 bytes 010 32 bytes 011 64 bytes 100 128 bytes 101 256 bytes 110 512 bytes 111 1024 bytes (1)
644 32015a?avr32?02/07 AT32AP7001 endpoint type: ? bk_number: number of banks read and write: set this field according to the endpoint?s number of banks (see section 32.5.4 ?endpoint configuration? ). number of banks ? nb_trans: number of tr ansaction per microframe read and write: the number of transactions per microframe is set by software. note: meaningful for high bandwidth isochronous endpoint only. ? ept_mapd: endpoint mapped read-only: 0 = the user should reprogram the register with correct values. 1 = set by hardware when the endpoint size (ept_size) an d the number of banks (bk_number) are correct regarding: ? the fifo max capacity (fifo_max_size in ipfeatures register) ? the number of endpoints/banks already allocated ? the number of allowed banks for this endpoint 00 control endpoint 01 isochronous endpoint 10 bulk endpoint 11 interrupt endpoint 00 zero bank, the endpoint is not mapped in memory 01 one bank (bank 0) 10 double bank (ping-pong: bank 0/bank 1) 11 triple bank (bank 0/bank 1/bank 2)
645 32015a?avr32?02/07 AT32AP7001 32.6.18 usba endpoint control enable register name: eptctlenbx access type: write-only for additional information, see ?usba endpoint control register? on page 649 . ? ept_enabl: endpoint enable 0 = no effect. 1 = enable endpoint according to the device configuration. ? auto_valid: packet auto-valid enable 0 = no effect. 1 = enable this bit to automatically validate the current packet and switch to the next bank for both in and out transfers. ? intdis_dma: interrupts disable dma 0 = no effect. 1 = if set, when an enabled endpoint-originated interrupt is triggered, the dma request is disabled. ? nyet_dis: nyet disable (only fo r high speed bulk out endpoints) 0 = no effect. 1 = forces an ack response to the next high spee d bulk out transfer instead of a nyet response. ? datax_rx: datax interrupt enable (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = enable datax interrupt. ? mdata_rx: mdata interrupt enable (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = enable mdata interrupt. 31 30 29 28 27 26 25 24 shrt_pckt??????? 23 22 21 20 19 18 17 16 ?????busy_bank?? 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy err_ovflw 76543210 mdata_rx datax_rx ? nyet_dis intdis_dma ? auto_valid ept_enabl
646 32015a?avr32?02/07 AT32AP7001 ? err_ovflw: overflow error interrupt enable 0 = no effect. 1 = enable overflow error interrupt. ? rx_bk_rdy: received out data interrupt enable 0 = no effect. 1 = enable received out data interrupt. ? tx_complt: transmitted in data complete interrupt enable 0 = no effect. 1 = enable transmitted in data complete interrupt. ? tx_pk_rdy/err_trans: tx packet read y/transaction error interrupt enable 0 = no effect. 1 = enable tx packet ready/transaction error interrupt. ? rx_setup/err_fl_iso: received set up/error flow interrupt enable 0 = no effect. 1 = enable rx_setup/error flow iso interrupt. ? stall_snt/err_criso/err_nbtra: stal l sent /iso crc error/number of transaction error interrupt enable 0 = no effect. 1 = enable stall sent/error crc iso/erro r number of tran saction interrupt. ? nak_in/err_flush: nakin/bank flush error interrupt enable 0 = no effect. 1 = enable nakin/bank flush error interrupt. ? nak_out: nakout interrupt enable 0 = no effect. 1 = enable nakout interrupt. ? busy_bank: busy bank interrupt enable 0 = no effect. 1 = enable busy bank interrupt. ? shrt_pckt: short packet send/short packet interrupt enable for out endpoints: 0 = no effect. 1 = enable short packet interrupt. for in endpoints: guarantees short packet at end of dma transfer if the dmacontrolx register end_b_en and eptctlx register autovalid bits are also set.
647 32015a?avr32?02/07 AT32AP7001 32.6.19 usba endpoint control disable register name: eptctldisx access type: write-only for additional information, see ?usba endpoint control register? on page 649 . ? ept_disabl: endpoint disable 0 = no effect. 1 = disable endpoint. ? auto_valid: packet auto-valid disable 0 = no effect. 1 = disable this bit to not automatically validate the current packet. ? intdis_dma: interrupts disable dma 0 = no effect. 1 = disable the ?interrupts disable dma?. ? nyet_dis: nyet enable (only for high speed bulk out endpoints) 0 = no effect. 1 = let the hardware handle the handshake response for the high speed bulk out transfer. ? datax_rx: datax interrupt disable (only fo r high bandwidth isochronous out endpoints) 0 = no effect. 1 = disable datax interrupt. ? mdata_rx: mdata interrupt disable (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = disable mdata interrupt. 31 30 29 28 27 26 25 24 shrt_pckt??????? 23 22 21 20 19 18 17 16 ?????busy_bank?? 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy err_ovflw 76543210 mdata_rx datax_rx ? nyet_dis intdis_dma ? auto_valid ept_disabl
648 32015a?avr32?02/07 AT32AP7001 ? err_ovflw: overflow error interrupt disable 0 = no effect. 1 = disable overflow error interrupt. ? rx_bk_rdy: received out data interrupt disable 0 = no effect. 1 = disable received out data interrupt. ? tx_complt: transmitted in data complete interrupt disable 0 = no effect. 1 = disable transmitted in data complete interrupt. ? tx_pk_rdy/err_trans: tx packet read y/transaction error interrupt disable 0 = no effect. 1 = disable tx packet ready/transaction error interrupt. ? rx_setup/err_fl_iso: received setup /error flow interrupt disable 0 = no effect. 1 = disable rx_setup/error flow iso interrupt. ? stall_snt/err_criso/err_nbtra: stall sent/iso crc er ror/number of transacti on error interrupt disable 0 = no effect. 1 = disable stall sent/error crc iso/error number of transaction interrupt. ? nak_in/err_flush: nakin/bank flush error interrupt disable 0 = no effect. 1 = disable nakin/ bank flush error interrupt. ? nak_out: nakout interrupt disable 0 = no effect. 1 = disable nakout interrupt. ? busy_bank: busy bank interrupt disable 0 = no effect. 1 = disable busy bank interrupt. ? shrt_pckt: short packet interrupt disable for out endpoints: 0 = no effect. 1 = disable short packet interrupt. for in endpoints: never automatically add a zero length packet at end of dma transfer. .
649 32015a?avr32?02/07 AT32AP7001 32.6.20 usba endpoint control register name: eptctlx access type: read-only ? ept_enabl: endpoint enable 0 = if cleared, the endpoint is disabled according to the devi ce configuration. endpoint 0 should always be enabled after a hardware or usba bus reset and participate in the device configuration. 1 = if set, the endpoint is enabled according to the device configuration. ? auto_valid: packet auto-valid enabled (not for control endpoints) set this bit to automatically validate the current packet and switch to the next bank for both in and out endpoints. for in transfer: if this bit is set, then the eptstax register tx_pk_rdy bit is set automatically when the current bank is full and at the end of dma buffer if the dmacontrolx register end_b_en bit is set. the user may still set the eptstax register tx_pk_rdy bit if the current bank is not full, unless the user wants to send a zero length packet by software. for out transfer: if this bit is set, then the eptstax register rx_bk_rdy bit is automatically reset for the current bank when the last packet byte has been read from the bank fifo or at the end of dma buffer if the dm acontrolx regi ster end_b_en bit is set. for example, to truncate a padded data pack et when the actual data transfer size is reached. the user may still clear the eptstax regi ster rx_bk_rdy bit, for ex ample, after comp leting a dma buffer by software if dmacontrolx register end_b_en bit was disabled or in order to cancel the read of the remaining data bank(s). ? intdis_dma: interrupt disables dma if set, when an enabled endpoint-originated interrupt is tri ggered, the dma request is disabled regardless of the ien regis- ter ept_int_x bit for this endpoint. then, the firmware will have to clear or disable the interrupt source or clear this bit if transfer completion is needed. if the exception raised is associated with the new system bank packet, then the previous dma packet transfer is normally completed, but the new dma packet transfer is not started (not requested). if the exception raised is not associated to a new system bank packet (nak_in, nak_out, err_fl_iso...), then the request cancellation may happen at any time and may immediately stop the current dma transfer. 31 30 29 28 27 26 25 24 shrt_pckt??????? 23 22 21 20 19 18 17 16 ?????busy_bank?? 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy err_ovflw 76543210 mdata_rx datax_rx ? nyet_dis intdis_dma ? auto_valid ept_enabl
650 32015a?avr32?02/07 AT32AP7001 this may be used, for example, to identify or prevent an erroneous packet to be transferred into a buffer or to complete a dma buffer by software after reception of a short packet, or to perform buffer truncation on err_fl_iso interrupt for adaptive rate. ? nyet_dis: nyet disable (only for high speed bulk out endpoints) 0 = if clear, this bit lets the hardware handle the handshake response for the high speed bulk out transfer. 1 = if set, this bit forces an ack response to the next high speed bulk out transfer instead of a nyet response. note: according to the universal serial bus specification, rev 2.0 (8.5.1.1 nak responses to out/ data during ping protocol), a nak response to an hs bulk out transfer is expected to be an unusual occurrence. ? datax_rx: datax interrupt enabled (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = send an interrupt when a data2, da ta1 or data0 packet has been received meaning the whole microframe data payload has been received. ? mdata_rx: mdata interrupt enabled (only for high bandwidth isochronous out endpoints) 0 = no effect. 1 = send an interrupt when an mdata packet has been received and so at least one packet of the microframe data pay- load has been received. ? err_ovflw: overflow error interrupt enabled 0 = overflow error interrupt is masked. 1 = overflow error interrupt is enabled. ? rx_bk_rdy: received out data interrupt enabled 0 = received out data interrupt is masked. 1 = received out data interrupt is enabled. ? tx_complt: transmitted in data complete interrupt enabled 0 = transmitted in data co mplete interrupt is masked. 1 = transmitted in data comp lete interrupt is enabled. ? tx_pk_rdy/err_trans: tx packet read y/transaction error interrupt enabled 0 = tx packet ready/transaction error interrupt is masked. 1 = tx packet ready/transaction error interrupt is enabled. caution: interrupt source is active as long as the correspondi ng eptstax register tx_pk_rdy flag remains low. if there are no more banks available for transmitting after the software has set eptstax/tx_pk_rdy for the last trans- mit packet, then the interrupt source remains inacti ve until the first bank becomes free again to transmit at eptstax/tx_pk_rdy hardware clear. ? rx_setup/err_fl_iso: received setup /error flow interrupt enabled 0 = received setup/error flow interrupt is masked. 1 = received setup/error flow interrupt is enabled.
651 32015a?avr32?02/07 AT32AP7001 ? stall_snt/err_criso/err_nbtra: stall sent/iso crc er ror/number of transaction error interrupt enabled 0 = stall sent/iso crc error/number of transaction error interrupt is masked. 1 = stall sent /iso crc error/number of transaction error interrupt is enabled. ? nak_in/err_flush: nakin/bank flush error interrupt enabled 0 = nakin interrupt is masked. 1 = nakin/bank flush error interrupt is enabled. ? nak_out: nakout interrupt enabled 0 = nakout interrupt is masked. 1 = nakout interrupt is enabled. ? busy_bank: busy bank interrupt enabled 0 = busy_bank interrupt is masked. 1 = busy_bank interrupt is enabled. for out endpoints : an interrupt is sent when all banks are busy. for in endpoints: an interrupt is sent when all banks are free . ? shrt_pckt: short packet interrupt enabled for out endpoints : send an interrupt when a short packet has been received. 0 = short packet interrupt is masked. 1 = short packet interrupt is enabled. for in endpoints : a short packet transmission is guaranteed upon end of the dma transfer, thus signaling a bulk or interrupt end of transfer or an end of isochronous (m icro-)frame data, but only if the dmacontrolx register end_b_en and eptctlx register auto_valid bits are also set.
652 32015a?avr32?02/07 AT32AP7001 32.6.21 usba endpoint set status register name: eptsetstax access type: write-only ? frcestall: stall handshake request set 0 = no effect. 1 = set this bit to request a stall answer to the host for the next handshake refer to chapters 8.4.5 (handshake packets) and 9.4.5 (get status) of the universal serial bus sp ecification, rev 2.0 for more information on the stall handshake. ? kill_bank: kill bank set (for in endpoint) 0 = no effect. 1 = kill the last written bank. ? tx_pk_rdy: tx packet ready set 0 = no effect. 1 = set this bit after a packet has been written into the endpoint fifo for in data transfers ? this flag is used to generate a data in transaction (device to host). ? device firmware checks that it can write a data payload in the fifo, checking that tx_pk_rdy is cleared. ? transfer to the fifo is done by writing in the ?buffer address? register. ? once the data payload has been transferred to the fifo, the firmware notifi es the usba device setting tx_pk_rdy to one. ? usba bus transactions can start. ? txcomp is set once the data payload has been received by the host. ? data should be written into the endpoint fifo only after this bit has been cleared. ? set this bit without writing data to the endpoint fifo to send a zero length packet. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ????tx_pk_rdy?ki ll_bank ? 76543210 ??frcestall?????
653 32015a?avr32?02/07 AT32AP7001 32.6.22 usba endpoint clear status register name: eptclrstax access type: write-only ? frcestall: stall handshake request clear 0 = no effect. 1 = clear the stall request. the next packets from host will not be stalled. ? togglesq: data toggle clear 0 = no effect. 1 = clear the pid data of the current bank for out endpoints, the next received packet should be a data0. for in endpoints, the next pa cket will be sent with a data0 pid. ? rx_bk_rdy: receive d out data clear 0 = no effect. 1 = clear the rx_bk_rdy flag of eptstax. ? tx_complt: transmitted in data complete clear 0 = no effect. 1 = clear the tx_complt flag of eptstax. ? rx_setup/err_fl_iso: received setup/error flow clear 0 = no effect. 1 = clear the rx_setup/err_fl_iso flags of eptstax. ? stall_snt/err_nbtra: stall sent/number of transaction error clear 0 = no effect. 1 = clear the stall_snt/err_nbtra flags of eptstax. ? nak_in/err_flush: nakin/bank flush error clear 0 = no effect. 1 = clear the nak_in/err_flush flags of eptstax. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_nbtra rx_setup/ err_fl_iso ? tx_complt rx_bk_rdy ? 76543210 ?togglesqfrcestall?????
654 32015a?avr32?02/07 AT32AP7001 ? nak_out: nakout clear 0 = no effect. 1 = clear the nak_out flag of eptstax.
655 32015a?avr32?02/07 AT32AP7001 32.6.23 usba endpoint status register name: eptstax access type: read-only ? frcestall: stall handshake request 0 = no effect. 1= if set a stall answer will be done to the host for the next handshake. this bit is reset by hardware upon received setup. ? togglesq_sta: toggle sequencing toggle sequencing: in endpoint : it indicates the pid data toggle that will be used for the next packet sent. this is not relative to the current bank. control and out endpoint : these bits are set by hardware to indicate the pid data of the current bank: note 1: in out transfer, the toggle information is meaningful only when the current bank is busy (received out data = 1). note 2: these bits are updated for out transfer: ? a new data has been written into the current bank. ? the user has just cleared the received out data bit to switch to the next bank. note 3: for high bandwidth isochronous out endpoint, it is recommended to check the eptstax/err_trans bit to know if the toggle sequencing is correct or not. note 4: this field is reset to data1 by the eptclrstax register togglesq bit, and by eptctldisx (disable endpoint). 31 30 29 28 27 26 25 24 shrt_pckt byte_count 23 22 21 20 19 18 17 16 byte_count busy_bank_sta current_bank/ control_dir 15 14 13 12 11 10 9 8 nak_out nak_in/ err_flush stall_snt/ err_criso/ err_nbtra rx_setup/ err_fl_iso tx_pk_rdy/ err_trans tx_complt rx_bk_rdy/ kill_bank err_ovflw 76543210 togglesq_stafrcestall????? 00 data0 01 data1 10 data2 (only for high bandwidth isochronous endpoint) 11 mdata (only for high bandwidth isochronous endpoint)
656 32015a?avr32?02/07 AT32AP7001 ? err_ovflw: overflow error this bit is set by hardware when a new too-long packet is received. example: if the user programs an endpoint 64 bytes wide and th e host sends 128 bytes in an out transfer, then the over- flow error bit is set. this bit is updated at the same time as the byte_count field. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). ? rx_bk_rdy/kill_bank: rece ived out data/kill bank received out data : (for out endpoint or control endpoint) this bit is set by hardware after a new packet has been stored in the endpoint fifo. this bit is cleared by the device firmware af ter reading the out data from the endpoint. for multi-bank endpoints, this bit may remain active even when cleared by the device firmware, this if an other packet has been received meanwhile. hardware assertion of this bit may generate an interrupt if enabled by the eptctlx register rx_bk_rdy bit. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). kill bank : (for in endpoint) ? the bank is really cleared or the bank is sent, busy_bank_sta is decremented. ? the bank is not cleared but sent on the in transfer, tx_complt ? the bank is not cleared because it was empty. the user sh ould wait that this bit is cleared before trying to clear another packet. note: ?kill a packet? may be refused if at t he same time, an in token is coming and the current packet is sent on the usba line. in this case, the tx_complt bit is set. take notice however, that if at least two banks are ready to be sent, there is no problem to kill a packet even if an in token is coming. in fa ct, in that case, the current bank is sent (in transfer) and th e last bank is killed. ? tx_complt: transmitted in data complete this bit is set by hardware after an in packet has been transmitted for isochronous endpoints and after it has been accepted (ack?ed) by the host for control, bulk and interrupt endpoints. this bit is reset by eptrst register rst_ept_x (reset endpoint), and by eptctldisx (disable endpoint). ? tx_pk_rdy/err_trans: tx packet ready/transaction error tx packet ready: this bit is cleared by hardware, as soon as the packet has been sent for isochronous endpoints, or after the host has acknowledged the packet for control, bulk and interrupt endpoints. for multi-bank endpoints, this bit may remain clear even afte r software is set if another bank is available to transmit. hardware clear of this bit may generate an interrupt if enabled by the eptctlx register tx_pk_rdy bit. this bit is reset by eptrst register rst_ept_x (reset endpoint), and by eptctldisx (disable endpoint). transaction error : (for high bandwidth isochronous out endpoints) (read-only) this bit is set by hardware when a transa ction error occurs inside one microframe. if one toggle sequencing problem occurs amo ng the n-transactions (n = 1, 2 or 3) in side a microframe, then this bit is still set as long as the current bank contains one ?bad? n-transaction. (see ?current_bank/control_dir: current
657 32015a?avr32?02/07 AT32AP7001 bank/control direction? on page 658 ) as soon as the current bank is relative to a new ?good? n-transactions, then this bit is reset. note1 : a transaction error occurs when the toggle sequencing does not respect the universal serial bus specification, rev 2.0 (5.9.2 high bandwidth isochronous endpoints) (bad pid, missing data....) note2 : when a transaction error occurs, the user may empty all the ?bad? transactions by clearing the received out data flag (rx_bk_rdy). if this bit is reset, then the user should consider that a new n-transaction is coming. this bit is reset by eptrst register rst_ept_x (reset endpoint), and by eptctldisx (disable endpoint). ? rx_setup/err_fl_iso: received setup/error flow received setup : (for control endpoint only) this bit is set by hardware when a valid setup packet has been received from the host. it is cleared by the device firmware after reading the setup data from the endpoint fifo. this bit is reset by eptrst register rst_ept_x (reset endpoint), and by eptctldisx (disable endpoint). error flow : (for isochronous endpoint only) this bit is set by hardware w hen a transaction error occurs. ? isochronous in transaction is missed, the micr o has no time to fill t he endpoint (underflow). ? isochronous out data is dropped because the bank is busy (overflow). this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). ? stall_snt/err_criso/err_nbtra: stall sent/c rc iso error/number of transaction error stall_snt : (for control, bulk and interrupt endpoints) this bit is set by hardware after a stall handshake has bee n sent as requested by the eptstax register frcestall bit. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). err_criso : (for isochronous out endpoints) (read-only) this bit is set by hardware if the last received data is corrupted (crc error on data). this bit is updated by hardware when new data is received (received out data bit). err_nbtra : (for high bandwidth isochronous in endpoints) this bit is set at the end of a microframe in which at l east one data bank has been transmitted, if less than the number of transactions per micro-frame banks (eptcfgx register nb _trans) have been validated for transmission inside this microframe. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). ? nak_in/err_flush: nak in/bank flush error nak_in : this bit is set by hardware when a nak handshake has bee n sent in response to an in request from the host. this bit is cleared by software. err_flush : (for high bandwidth isochronous in endpoints) this bit is set when flushing unsent banks at the end of a microframe.
658 32015a?avr32?02/07 AT32AP7001 this bit is reset by eptrst register rst_ept_x (reset endpoint) and by ept_ctl_disx (disable endpoint). ? nak_out: nak out this bit is set by hardware when a nak handshake has been sent in response to an out or ping request from the host. this bit is reset by eptrst register rst_ept_x (reset endpoint) and by ept_ctl_disx (disable endpoint). ? current_bank/control_dir: cu rrent bank/control direction current bank : (all endpoints except control endpoint) these bits are set by hardware to indicate the number of the current bank. note: the current bank is updated each time the user: ? sets the tx packet ready bit to prepare the next in transfer and to switch to the next bank. ? clears the received out data bit to access the next bank. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint). control direction : (for control endpoint only) 0 = a control write is requested by the host. 1 = a control read is requested by the host. note1: this bit corresponds with the 7th bit of the bmrequesttype (byte 0 of the setup data). note2: this bit is updated after receiving new setup data. ? busy_bank_sta: busy bank number these bits are set by hardware to indicate the number of busy banks. in endpoint : it indicates the number of busy banks filled by the us er, ready for in transfer. out endpoint : it indicates the number of busy banks filled by out transaction from the host. ? byte_count: usba byte count byte count of a received data packet. this field is incremented after each write into the endpoint (to prepare an in transfer). this field is decremented after each reading into the endpoint (out transfer). this field is also updated at rx_bk_rdy flag clear with the next bank. this field is also updated at tx_pk_rdy flag set with the next bank. 00 bank 0 (or single bank) 01 bank 1 10 bank 2 11 invalid 00 all banks are free 01 1 busy bank 10 2 busy banks 11 3 busy banks
659 32015a?avr32?02/07 AT32AP7001 this field is reset by rst_ept_x of eptrst register. ? shrt_pckt: short packet an out short packet is detected when the receive byte count is less than the configured eptcfgx register ept_size. this bit is updated at the same time as the byte_count field. this bit is reset by eptrst register rst_ept_x (r eset endpoint) and by eptctldisx (disable endpoint).
660 32015a?avr32?02/07 AT32AP7001 32.6.24 usba dma channel transfer descriptor the dma channel transfer descriptor is loaded from the memory. be careful with the alignment of this buffer. the structure of the dma channel transfer descriptor is defined by three parameters as described below: offset 0: the address must be aligned: 0xxxxx0 next descriptor address register: dmanxtdscx offset 4: the address must be aligned: 0xxxxx4 dma channelx address register: dmaaddressx offset 8: the address must be aligned: 0xxxxx8 dma channelx control register: dmacontrolx to use the dma channel transfer descriptor, fill the structures with the correct va lue (as described in the following pages). then write directly in dmanxtdscx the address of the descriptor to be used first. then write 1 in the ldnxt_dsc bit of dmacontrolx (load next channel transfer descriptor). the descriptor is automat- ically loaded upon endpointx request for packet transfer.
661 32015a?avr32?02/07 AT32AP7001 32.6.25 usba dma next descriptor address register name: dmanxtdscx access type: read/write ? nxt_dsc_add this field points to the next channel descri ptor to be processed. this channel descri ptor must be aligned, so bits 0 to 3 of the address must be equal to zero. 31 30 29 28 27 26 25 24 nxt_dsc_add 23 22 21 20 19 18 17 16 nxt_dsc_add 15 14 13 12 11 10 9 8 nxt_dsc_add 76543210 nxt_dsc_add
662 32015a?avr32?02/07 AT32AP7001 32.6.26 usba dma channelx address register name: dmaaddressx access type: read/write ? buff_add this field determines the hsb bus starting address of a dma channel transfer. channel start and end addresses may be aligned on any byte boundary. the firmware may write this field only when th e dmastatus register chann_enb bit is clear. this field is updated at the end of the address phase of the current access to the hsb bus. it is incrementing of the access byte width. the access width is 4 bytes (or less) at packet start or end, if the start or end address is not aligned on a word boundary. the packet start address is either the channel start addres s or the next channel address to be accessed in the channel buffer. the packet end address is either the channel end address or the latest channel address accessed in the channel buffer. the channel start address is written by software or loaded fr om the descriptor, whereas the channel end address is either determined by the end of buffer or th e usba device, usb end of tr ansfer if the dmacontrolx register end_tr_en bit is set. 31 30 29 28 27 26 25 24 buff_add 23 22 21 20 19 18 17 16 buff_add 15 14 13 12 11 10 9 8 buff_add 76543210 buff_add
663 32015a?avr32?02/07 AT32AP7001 32.6.27 usba dma channelx control register name: dmacontrolx access type: read/write ? chann_enb (channel enable command) 0 = dma channel is disabled at and no transfer will occur upon request. this bit is also cl eared by hardware when the chan- nel source bus is disabled at end of buffer. if the dmacontrol register ldnxt_ds c bit has been cleared by descriptor lo ading, the firmware will have to set the corresponding chann_enb bit to start the described transfer, if needed. if the dmacontrol register ldnxt_dsc bit is cleared, t he channel is frozen and the channel registers may then be read and/or written reliably as soon as both dmasta tus register chann_enb and chann_act flags read as 0. if a channel request is currently serviced when this bit is clear ed, the dma fifo buffer is drained until it is empty, then the dmastatus register chann_enb bit is cleared. if the ldnxt_dsc bit is set at or after this bit clearing, then the currently loaded descriptor is skipped (no data transfer occurs) and the next descriptor is immediately loaded. 1 = dmastatus register chann_enb bit will be set, thus enabling dma channel data transfer. then any pending request will start the transfer. th is may be used to start or resume any requested transfer. ? ldnxt_dsc: load next channel transfer descriptor enable (command) 0 = no channel register is loaded after the end of the channel transfer. 1 = the channel controller loads the next descriptor after the end of the current transfer, i.e. when the dmasta- tus/chann_enb bit is reset. if the dma control/chann_enb bi t is cleared, the next descriptor is im mediately loaded upon transfer request. dma channel control command summary ? end_tr_en: end of transfer enable (control) 31 30 29 28 27 26 25 24 buff_length 23 22 21 20 19 18 17 16 buff_length 15 14 13 12 11 10 9 8 ???????? 76543210 burst_lck desc_ld_it end_buffit end_tr_it end_b_en end_tr_en ldnxt_dsc chann_enb ldnxt_dsc chann_enb description 0 0 stop now 0 1 run and stop at end of buffer 1 0 load next descriptor now 1 1 run and link at end of buffer
664 32015a?avr32?02/07 AT32AP7001 used for out transfers only. 0 = usb end of transfer is ignored. 1 = usba device can put an end to the current buffer transfer. when set, a bulk or interrupt short packet or the last packet of an isoc hronous (micro) frame (datax) will close the current buffe r and the dmastatusx register en d_tr_st flag will be raised. this is intended for usba non -prenegotiated end of transf er (bulk or interrupt) or isochronous microframe data buffer closure. ? end_b_en: end of buffer enable (control) 0 = dma buffer end has no impact on usb packet transfer. 1 = endpoint can validate the packet (according to the values programmed in the eptctlx register auto_valid and shrt_pckt fields) at dma buffer end, i.e. when the dmastatus register buff_count reaches 0. this is mainly for short packet in validation initiated by the dma reaching end of buffer, but could be used for out packet truncation (discarding of unwanted packet data) at the end of dma buffer. ? end_tr_it: end of transfer interrupt enable 0 = usba device initiated buffer transfe r completion will not trigger any in terrupt at statusx/end_tr_st rising. 1 = an interrupt is sent afte r the buffer tran sfer is complete, if the usba device has ende d the buffer transfer. use when the receive size is unknown. ? end_buffit: end of buffer interrupt enable 0 = dma_statusx/end_bf_st rising will not trigger any interrupt. 1 = an interrupt is generated when the dmastatusx register buff_count reaches zero. ? desc_ld_it: descriptor loaded interrupt enable 0 = dmastatusx/desc_ldst rising will not trigger any interrupt. 1 = an interrupt is generated when a descriptor has been loaded from the bus. ? burst_lck: burst lock enable 0 = the dma never locks bus access. 1 = usb packets hsb data bursts are locked for maximum opt imization of the bus bandwidth usage and maximization of fly-by hsb burst duration. ? buff_length: buffer byte length (write-only) this field determines the number of bytes to be transferred until end of buffer. the maximum channel transfer size (64 kb) is reached when this field is 0 (default value). if the transfer size is unknown, this field s hould be set to 0, but the transf er end may occur earlier under usba device control. when this field is written, the dmastatusx register buff_count fiel d is updated with the write value. note: bits [31:2] are only writable when issuin g a channel control command other than ?stop now?. note: for reliability it is highly recommended to wait for both dmastatusx register chan_act and chan_enb flags are at 0, thus ensuring the channel has been stopped befor e issuing a command other than ?stop now?.
665 32015a?avr32?02/07 AT32AP7001 32.6.28 usba dma channelx status register name: dmastatusx access type: read/write ? chann_enb: channel enable status 0 = if cleared, the dma channel no longer transfers data, and may load the next descriptor if the dmacontrolx register ldnxt_dsc bit is set. when any transfer is ended either due to an elapsed byte coun t or a usba device initiated tr ansfer end, this bit is automat- ically reset. 1 = if set, the dma channel is currently enabled and transfers data upon request. this bit is normally set or cleared by writing into the dmacontrolx register ch ann_enb bit field either by software or descriptor loading. if a channel request is currently serviced when the dmacontrolx register chann_enb bit is cleared, the dma fifo buffer is drained until it is empty, then this status bit is cleared. ? chann_act: channel active status 0 = the dma channel is no longer trying to source the packet data. when a packet transfer is ended this bit is automatically reset. 1 = the dma channel is currently trying to source packet da ta, i.e. selected as the highest-priority requesting channel. when a packet transfer cannot be completed due to an end_bf_st, this flag stays set during the next channel descriptor load (if any) and potent ially until usba packet trans fer completion, if allowed by the new descriptor. ? end_tr_st: end of channel transfer status 0 = cleared automatically when read by software. 1 = set by hardware when the last packet transfer is complete, if the usba device has ended the transfer. valid until the chann_enb flag is cleared at the end of the next buffer transfer. ? end_bf_st: end of channel buffer status 0 = cleared automatically when read by software. 1 = set by hardware when the buff_count downcount reach zero. valid until the chann_enb flag is cleared at the end of the next buffer transfer. 31 30 29 28 27 26 25 24 buff_count 23 22 21 20 19 18 17 16 buff_count 15 14 13 12 11 10 9 8 ???????? 76543210 ? desc_ldst end_bf_st end_tr_st ? ? chann_act chann_enb
666 32015a?avr32?02/07 AT32AP7001 ? desc_ldst: descriptor loaded status 0 = cleared automatically when read by software. 1 = set by hardware when a descriptor has been loaded from the system bus. valid until the chann_enb flag is cleared at the end of the next buffer transfer. ? buff_count: buffer byte count this field determines the current number of bytes still to be transfer red for this buffer. this field is decremented from the hsb source bus access byte width at the end of this bus address phase. the access byte width is 4 by default, or less, at dma start or end, if the start or end address is not aligned on a word boundary. at the end of buffer, the dma accesses the usba device only for the number of byte s needed to complete it. this field value is reliable (stable) only if the channel has been stopped or frozen (eptctlx register nt_dis_dma bit is used to disable the channel request) and the chann el is no longer active chann_act flag is 0. note: for out endpoints, if the receive buffer byte length (b uff_length) has been defaulted to zero because the usb transfer length is unknown, the actual buffer by te length received will be 0x10000-buff_count.
667 32015a?avr32?02/07 AT32AP7001 33. timer/counter (tc) rev: 6082c 33.1 features ? three 16-bit timer counter channels ? a wide range of functions including: ? frequency measurement ? event counting ? interval measurement ? pulse generation ? delay timing ? pulse width modulation ? up/down capabilities ? each channel is user-configurable and contains: ? three external clock inputs ? five internal clock inputs ? two multi-purpose input/output signals ? internal interrupt signal ? two global registers that act on all three tc channels 33.2 description the timer counter (tc) includes three identical 16-bit timer counter channels. each channel can be independently programmed to perform a wide range of functions including frequency measurement, event counting, interval measurement, pulse generation, delay timing and pulse width modulation. each channel has three external clock inputs, fi ve internal clock inputs and two multi-purpose input/output signals which can be configured by the user. each channel drives an internal inter- rupt signal which can be programmed to generate processor interrupts. the timer counter block has two global registers which act upon all three tc channels. the block control register allows the three channels to be started simultaneously with the same instruction. the block mode register defines the external clock inputs for each channel, allowing them to be chained.
668 32015a?avr32?02/07 AT32AP7001 33.3 block diagram figure 33-1. timer counter block diagram table 33-1. signal name description block/channel sign al name description channel signal xc0, xc1, xc2 external clock inputs tioa capture mode: timer counter input waveform mode: timer counter output tiob capture mode: timer counter input waveform mode: timer counter input/output int interrupt signal output sync synchronization input signal timer/counter channel 0 timer/counter channel 1 timer/counter channel 2 sync parallel i/o controller tc1xc1s tc0xc0s tc2xc2s int0 int1 int2 tioa0 tioa1 tioa2 tiob0 tiob1 tiob2 xc0 xc1 xc2 xc0 xc1 xc2 xc0 xc1 xc2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tclk0 tclk1 tclk2 tioa1 tioa2 tioa0 tioa2 tioa0 tioa1 interrupt controller tclk0 tclk1 tclk2 tioa0 tiob0 tioa1 tiob1 tioa2 tiob2 timer counter tioa tiob tioa tiob tioa tiob sync sync timer_clock2 timer_clock3 timer_clock4 timer_clock5 timer_clock1
669 32015a?avr32?02/07 AT32AP7001 33.4 pin name list 33.5 product dependencies 33.5.1 i/o lines the pins used for interfacing the compliant ex ternal devices may be multiplexed with pio lines. the programmer must first program the pio controllers to assign the tc pins to their peripheral functions. 33.5.2 power management the timer counter clock is generated by the power manager. before using the tc, the program- mer must ensure that the tc clock is enabled in the power manager. 33.5.3 interrupt the tc has an interrupt line connected to the interrupt controller. handling the tc interrupt requires programming the interrupt controller before configuring the tc. 33.6 functional description 33.6.1 tc description the three channels of the timer counter are independent and identical in operation. the regis- ters for channel programming are listed in table 33-4 on page 682 . 33.6.1.1 16-bit counter each channel is organized around a 16-bit counter. the value of the counter is incremented at each positive edge of the selected clock. when the counter has reached the value 0xffff and passes to 0x0000, an overflow occurs and th e covfs bit in sr (status register) is set. the current value of the counter is accessible in real time by reading the counter value regis- ter, cv. the counter can be reset by a trigger. in this case, the counter value passes to 0x0000 on the next valid edge of the selected clock. 33.6.1.2 clock selection at block level, input clock signals of each channel can either be connected to the external inputs tclk0, tclk1 or tclk2, or be connected to the configurable i/o signals tioa0, tioa1 or tioa2 for chaining by programming the bmr (block mode). see figure 33-2 . each channel can independently select an internal or external clock source for its counter: table 33-2. tc pin list pin name description type tclk0-tclk2 external clock input input tioa0-tioa2 i/o line a i/o tiob0-tiob2 i/o line b i/o
670 32015a?avr32?02/07 AT32AP7001 ? internal clock signals: timer_cl ock1, timer_clock2, timer_clock3, timer_clock4, timer_clock5. the peripherals chapter details the connection of these clock sources. ? external clock signals: xc0, xc1 or xc2. the peripherals chapter details the connection of these clock sources. this selection is made by the tcclks bits in the tc channel mode register . the selected clock can be inverted with the clki bit in cmr. this allows counting on the oppo- site edges of the clock. the burst function allows the clock to be validat ed when an external signal is high. the burst parameter in the mode register defines this signal (none, xc0, xc1, xc2). note: in all cases, if an external clock is used, the du ration of each of its leve ls must be longer than the master clock period. the external clock frequen cy must be at least 2.5 times lower than the mas- ter clock figure 33-2. clock selection 33.6.1.3 clock control the clock of each counter can be controlled in two different ways: it can be enabled/disabled and started/stopped. see figure 33-3 . ? the clock can be enabled or disabled by the user with the clken and the clkdis commands in the control register. in capture mode it can be disabled by an rb load event if ldbdis is set to 1 in cmr. in waveform mode, it can be disabled by an rc compare event if cpcdis is set to 1 in cmr. when disabled, the start or the stop actions have no effect: only a clken command in the control register can re-enable the clock. when the clock is enabled, the clksta bit is set in the status register. ? the clock can also be started or stopped: a trigger (software, synchro, external or compare) always starts the clock. the clock can be stopped by an rb load event in capture mode timer_clock1 timer_clock2 timer_clock3 timer_clock4 timer_clock5 xc0 xc1 xc2 tcclks clki burst 1 selected clock
671 32015a?avr32?02/07 AT32AP7001 (ldbstop = 1 in cmr) or a rc compare event in waveform mode (cpcstop = 1 in cmr). the start and the stop commands have effect only if the clock is enabled. figure 33-3. clock control 33.6.1.4 tc operating modes each channel can independently operate in two different modes: ? capture mode provides measurement on signals. ? waveform mode provides wave generation. the tc operating mode is prog rammed with the wave bit in th e tc channel mode register. in capture mode, tioa and tiob are configured as inputs. in waveform mode, tioa is always configured to be an output and tiob is an output if it is not selected to be the external trigger. 33.6.1.5 trigger a trigger resets the counter and starts the counter clock. three types of triggers are common to both modes, and a fourth external trigger is available to each mode. the following triggers are common to both modes: ? software trigger: each channel has a software trigger, available by setting swtrg in ccr. ? sync: each channel has a synchronization signal sync. when asserted, this signal has the same effect as a software trigger. the sync signals of all channels are asserted simultaneously by writing bcr (block control) with sync set. ? compare rc trigger: rc is implemented in each channel and can provide a trigger when the counter value matches the rc val ue if cpctrg is set in cmr. the channel can also be configured to have an external trigger. in capture mode, the external trigger signal can be selected between tioa and tiob. in waveform mode, an external event can be programmed on one of the following signals: tiob, xc0, xc1 or xc2. this external event can then be programmed to perform a trigger by setting enetrg in cmr. qs r s r q clksta clken clkdis stop event disable event counter clock selected clock trigger
672 32015a?avr32?02/07 AT32AP7001 if an external trigger is used, the duration of the pulses must be longer than the master clock period in order to be detected. regardless of the trigger used, it will be taken into account at the following active edge of the selected clock. this means that the counter value can be read differently from zero just after a trigger, especially when a low frequency signal is selected as the clock. 33.6.2 capture operating mode this mode is entered by clearing the wave parameter in cmr (channel mode register). capture mode allows the tc channel to perform measurements such as pulse timing, fre- quency, period, duty cycle and phase on tioa and tiob sig nals which are considered as inputs. figure 33-4 shows the configuration of the tc channel when programmed in capture mode. 33.6.2.1 capture registers a and b registers a and b (ra and rb) are used as capture registers. this means that they can be loaded with the counter value when a progr ammable event occurs on the signal tioa. the ldra parameter in cmr defines the tioa edge for the loading of register a, and the ldrb parameter defines the tioa edge for the loading of register b. ra is loaded only if it has not been loaded since the last trigger or if rb has been loaded since the last loading of ra. rb is loaded only if ra has been loaded sinc e the last trigger or t he last loading of rb. loading ra or rb before the read of the last value loaded sets the overrun error flag (lovrs) in sr (status register). in this case, the old value is overwritten. 33.6.2.2 trigger conditions in addition to the sync signal, the software trigger and the rc compare trigger, an external trig- ger can be defined. the abetrg bit in cmr selects tioa or tiob input signal as an external trigger. the etrgedg parameter defines the ed ge (rising, falling or both) det ected to genera te an external trigger. if etrgedg = 0 (none), the external trigger is disabled.
673 32015a?avr32?02/07 AT32AP7001 figure 33-4. capture mode timer_clock1 timer_clock2 timer_clock3 timer_clock4 timer_clock5 xc0 xc1 xc2 tcclks clki qs r s r q clksta clken clkdis burst tiob register c capture register a capture register b compare rc = 16-bit counter abetrg swtrg etrgedg cpctrg tc1_imr trig ldrbs ldras etrgs tc1_sr lovrs covfs sync 1 mtiob tioa mtioa ldra ldbstop if ra is not loaded or rb is loaded if ra is loaded ldbdis cpcs int edge detector edge detector ldrb edge detector clk ovf reset timer/counter channel
674 32015a?avr32?02/07 AT32AP7001 33.6.3 waveform operating mode waveform operating mode is entered by setting the wave pa rameter in cmr (channel mode register). in waveform operating mode the tc channel generates 1 or 2 pwm signals with the same fre- quency and independently programmable duty cycles , or generates differe nt types of one-shot or repetitive pulses. in this mode, tioa is configured as an output and tiob is defined as an output if it is not used as an external event ( eevt parameter in cmr). figure 33-5 shows the configuration of the tc channel when programmed in waveform operat- ing mode. 33.6.3.1 waveform selection depending on the wavsel parameter in cmr (channel mode register), the behavior of cv varies. with any selection, ra, rb and rc can all be used as compare registers. ra compare is used to control the tioa output, rb compare is used to control the tiob output (if correctly configured) and rc compare is used to control tioa and/or tiob outputs.
675 32015a?avr32?02/07 AT32AP7001 figure 33-5. waveform mode tcclks clki qs r s r q clksta clken clkdis cpcdis burst tiob register a register b register c compare ra = compare rb = compare rc = cpcstop 16-bit counter eevt eevtedg sync swtrg enetrg wavsel tc1_imr trig acpc acpa aeevt aswtrg bcpc bcpb beevt bswtrg tioa mtioa tiob mtiob cpas covfs etrgs tc1_sr cpcs cpbs clk ovf reset output controller output controller int 1 edge detector timer/counter channel timer_clock1 timer_clock2 timer_clock3 timer_clock4 timer_clock5 xc0 xc1 xc2 wavsel
676 32015a?avr32?02/07 AT32AP7001 33.6.3.2 wavsel = 00 when wavsel = 00, the value of cv is increm ented from 0 to 0xffff. once 0xffff has been reached, the value of cv is reset. incrementation of cv starts again and the cycle continues. see figure 33-6 . an external event trigger or a software trigger can reset the value of cv. it is important to note that the trigger may occur at any time. see figure 33-7 . rc compare cannot be programmed to generate a trigger in this configuration. at the same time, rc compare can stop the counter clock (cpcstop = 1 in cmr) and/or disable the counter clock (cpcdis = 1 in cmr). figure 33-6. wavsel= 00 without trigger time counter value r c r b r a tiob tioa counter cleared by compare match with 0xffff 0xffff waveform examples
677 32015a?avr32?02/07 AT32AP7001 figure 33-7. wavsel= 00 with trigger 33.6.3.3 wavsel = 10 when wavsel = 10, the value of cv is incremented from 0 to the value of rc, then automati- cally reset on a rc compare. once the value of cv has been reset, it is then incremented and so on. see figure 33-8 . it is important to note that cv can be reset at any time by an external event or a software trigger if both are programmed correctly. see figure 33-9 . in addition, rc compare can stop the counter clock (cpcstop = 1 in cmr) and/or disable the counter clock (cpcdis = 1 in cmr). figure 33-8. wavsel = 10 without trigger time counter value r c r b r a tiob tioa counter cleared by compare match with 0xffff 0xffff waveform examples counter cleared by trigger time counter value r c r b r a tiob tioa counter cleared by compare match with rc 0xffff waveform examples
678 32015a?avr32?02/07 AT32AP7001 figure 33-9. wavsel = 10 with trigger 33.6.3.4 wavsel = 01 when wavsel = 01, the value of cv is incremented from 0 to 0xffff. once 0xffff is reached, the value of cv is decremented to 0, then re-incremented to 0xffff and so on. see figure 33-10 . a trigger such as an external event or a software trigger can modify cv at any time. if a trigger occurs while cv is incr ementing, cv then decrements. if a trig ger is received while cv is decre- menting, cv then increments. see figure 33-11 . rc compare cannot be programmed to generate a trigger in this configuration. at the same time, rc compare can stop the counter clock (cpcstop = 1) and/or disable the counter clock (cpcdis = 1). time counter value r c r b r a tiob tioa counter cleared by compare match with rc 0xffff waveform examples counter cleared by trigger
679 32015a?avr32?02/07 AT32AP7001 figure 33-10. wavsel = 01 without trigger figure 33-11. wavsel = 01 with trigger 33.6.3.5 wavsel = 11 when wavsel = 11, the value of cv is incremented from 0 to rc. once rc is reached, the value of cv is decremented to 0, then re-incremented to rc and so on. see figure 33-12 . a trigger such as an external event or a software trigger can modify cv at any time. if a trigger occurs while cv is incr ementing, cv then decrements. if a trig ger is received while cv is decre- menting, cv then increments. see figure 33-13 . rc compare can stop the counter clock (cpcstop = 1) and/or disable the counter clock (cpc- dis = 1). time counter value r c r b r a tiob tioa counter decremented by compare match with 0xffff 0xffff waveform examples time counter value tiob tioa counter decremented by compare match with 0xffff 0xffff waveform examples counter decremented by trigger counter incremented by trigger r c r b r a
680 32015a?avr32?02/07 AT32AP7001 figure 33-12. wavsel = 11 without trigger figure 33-13. wavsel = 11 with trigger 33.6.3.6 external event/trigger conditions an external event can be programmed to be detected on one of the clock sources (xc0, xc1, xc2) or tiob. the external event selected can then be used as a trigger. the eevt parameter in cmr sele cts the external trigger. th e eevtedg parameter defines the trigger edge for each of the possible external tr iggers (rising, falling or both). if eevtedg is cleared (none), no external event is defined. time counter value r c r b r a tiob tioa counter decremented by compare match with rc 0xffff waveform examples time counter value tiob tioa counter decremented by compare match with rc 0xffff waveform examples counter decremented by trigger counter incremented by trigger r c r b r a
681 32015a?avr32?02/07 AT32AP7001 if tiob is defined as an external event signal (eevt = 0), tiob is no longer used as an output and the compare register b is not used to generate waveforms and subsequently no irqs. in this case the tc channel can only generate a waveform on tioa. when an external event is defined, it can be used as a trigger by setting bit enetrg in cmr. as in capture mode, the sync signal and the softw are trigger are also available as triggers. rc compare can also be used as a trigger depending on the parameter wavsel. 33.6.3.7 output controller the output controller defines the output level changes on tioa and tiob following an event. tiob control is used only if tiob is defin ed as output (not as an external event). the following events control tioa and tiob: software trigger, external event and rc compare. ra compare controls tioa and rb compare controls tiob. each of these events can be pro- grammed to set, clear or toggle the output as defined in the corresponding parameter in cmr.
682 32015a?avr32?02/07 AT32AP7001 33.7 timer counter (tc) user interface bcr (block control register) and bmr (block mode register) control the whole tc block. tc channels are controlled by the registers listed in table 33-4 . the offset of each of the channel registers in table 33-4 is in relation to the offset of the corresponding channel as mentioned in table 33-4 . notes: 1. read-only if wave = 0 table 33-3. tc global memory map offset channel/register name access reset value 0x00 tc channel 0 see table 33-4 0x40 tc channel 1 see table 33-4 0x80 tc channel 2 see table 33-4 0xc0 tc block control register bcr write-only ? 0xc4 tc block mode register bmr read/write 0 table 33-4. tc channel memory map offset register name access reset value 0x00 channel control register ccr write-only ? 0x04 channel mode register cmr read/write 0 0x08 reserved ? 0x0c reserved ? 0x10 counter value cv read-only 0 0x14 register a ra read/write (1) 0 0x18 register b rb read/write (1) 0 0x1c register c rc read/write 0 0x20 status register sr read-only 0 0x24 interrupt enable register ier write-only ? 0x28 interrupt disable register idr write-only ? 0x2c interrupt mask register imr read-only 0
683 32015a?avr32?02/07 AT32AP7001 33.7.1 tc block control register register name: bcr access type: write-only ? sync: synchro command 0 = no effect. 1 = asserts the sync signal which generates a software trigger simultaneously for each of the channels. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ???????sync
684 32015a?avr32?02/07 AT32AP7001 33.7.2 tc block mode register register name: bmr access type: read/write ? tc0xc0s: external clock signal 0 selection ? tc1xc1s: external clock signal 1 selection ? tc2xc2s: external clock signal 2 selection 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ? ? tc2xc2s tc1xc1s tc0xc0s tc0xc0s signal connected to xc0 00tclk0 0 1 none 10tioa1 11tioa2 tc1xc1s signal connected to xc1 00tclk1 0 1 none 10tioa0 11tioa2 tc2xc2s signal connected to xc2 00tclk2 0 1 none 10tioa0 11tioa1
685 32015a?avr32?02/07 AT32AP7001 33.7.3 tc channel control register register name: ccr access type: write-only ? clken: counter clock enable command 0 = no effect. 1 = enables the clock if clkdis is not 1. ? clkdis: counter clock disable command 0 = no effect. 1 = disables the clock. ? swtrg: software trigger command 0 = no effect. 1 = a software trigger is performed: the counter is reset and the clock is started. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ?????swtrgclkdisclken
686 32015a?avr32?02/07 AT32AP7001 33.7.4 tc channel mode register: capture mode register name: cmr access type: read/write ? tcclks: clock selection ? clki: clock invert 0 = counter is incremented on rising edge of the clock. 1 = counter is incremented on falling edge of the clock. ? burst: burst signal selection ? ldbstop: counter clock stopped with rb loading 0 = counter clock is not stopped when rb loading occurs. 1 = counter clock is stopped when rb loading occurs. ? ldbdis: counter clock disable with rb loading 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ? ? ? ? ldrb ldra 15 14 13 12 11 10 9 8 wave = 0 cpctrg ? ? ? abetrg etrgedg 76543210 ldbdis ldbstop burst clki tcclks tcclks clock selected 000timer_clock1 001timer_clock2 010timer_clock3 011timer_clock4 100timer_clock5 101xc0 110xc1 111xc2 burst 0 0 the clock is not gated by an external signal. 0 1 xc0 is anded with the selected clock. 1 0 xc1 is anded with the selected clock. 1 1 xc2 is anded with the selected clock.
687 32015a?avr32?02/07 AT32AP7001 0 = counter clock is not disabl ed when rb loading occurs. 1 = counter clock is disabled when rb loading occurs. ? etrgedg: external trigger edge selection ? abetrg: tioa or tiob external trigger selection 0 = tiob is used as an external trigger. 1 = tioa is used as an external trigger. ? cpctrg: rc compare trigger enable 0 = rc compare has no effect on the counter and its clock. 1 = rc compare resets the counter and starts the counter clock. ?wave 0 = capture mode is enabled. 1 = capture mode is disabled (waveform mode is enabled). ? ldra: ra loading selection ? ldrb: rb loading selection etrgedg edge 0 0 none 0 1 rising edge 1 0 falling edge 1 1 each edge ldra edge 0 0 none 0 1 rising edge of tioa 1 0 falling edge of tioa 1 1 each edge of tioa ldrb edge 0 0 none 0 1 rising edge of tioa 1 0 falling edge of tioa 1 1 each edge of tioa
688 32015a?avr32?02/07 AT32AP7001 33.7.5 tc channel mode register: waveform mode register name: cmr access type: read/write ? tcclks: clock selection ? clki: clock invert 0 = counter is incremented on rising edge of the clock. 1 = counter is incremented on falling edge of the clock. ? burst: burst signal selection ? cpcstop: counter clock stopped with rc compare 0 = counter clock is not stopped when counter reaches rc. 1 = counter clock is stopped when counter reaches rc. ? cpcdis: counter clock disable with rc compare 31 30 29 28 27 26 25 24 bswtrg beevt bcpc bcpb 23 22 21 20 19 18 17 16 aswtrg aeevt acpc acpa 15 14 13 12 11 10 9 8 wave = 1 wavsel enetrg eevt eevtedg 76543210 cpcdis cpcstop burst clki tcclks tcclks clock selected 000timer_clock1 001timer_clock2 010timer_clock3 011timer_clock4 100timer_clock5 101xc0 110xc1 111xc2 burst 0 0 the clock is not gated by an external signal. 0 1 xc0 is anded with the selected clock. 1 0 xc1 is anded with the selected clock. 1 1 xc2 is anded with the selected clock.
689 32015a?avr32?02/07 AT32AP7001 0 = counter clock is not disabl ed when counter reaches rc. 1 = counter clock is disabled when counter reaches rc. ? eevtedg: external ev ent edge selection ? eevt: external event selection note: 1. if tiob is chosen as the external event signal, it is conf igured as an input and no longer generates waveforms and subse- quently no irqs . ? enetrg: external event trigger enable 0 = the external event has no effect on the counter and its clock. in this case, the selected external event only controls the tioa output. 1 = the external event resets the counter and starts the counter clock. ? wavsel: waveform selection ? wave = 1 0 = waveform mode is disabled (capture mode is enabled). 1 = waveform mode is enabled. eevtedg edge 0 0 none 0 1 rising edge 1 0 falling edge 1 1 each edge eevt signal selected as exte rnal event tiob direction 0 0 tiob input (1) 0 1 xc0 output 1 0 xc1 output 1 1 xc2 output wavsel effect 0 0 up mode without automatic trigger on rc compare 1 0 up mode with automa tic trigger on rc compare 0 1 updown mode without automatic trigger on rc compare 1 1 updown mode with automatic trigger on rc compare
690 32015a?avr32?02/07 AT32AP7001 ? acpa: ra compare effect on tioa ? acpc: rc compare effect on tioa ? aeevt: external event effect on tioa ? aswtrg: software trigger effect on tioa ? bcpb: rb compare effect on tiob acpa effect 0 0 none 0 1 set 1 0 clear 1 1 toggle acpc effect 0 0 none 0 1 set 1 0 clear 1 1 toggle aeevt effect 0 0 none 0 1 set 1 0 clear 1 1 toggle aswtrg effect 0 0 none 0 1 set 1 0 clear 1 1 toggle bcpb effect 0 0 none
691 32015a?avr32?02/07 AT32AP7001 ? bcpc: rc compare effect on tiob ? beevt: external event effect on tiob ? bswtrg: software trigger effect on tiob 0 1 set 1 0 clear 1 1 toggle bcpc effect 0 0 none 0 1 set 1 0 clear 1 1 toggle beevt effect 0 0 none 0 1 set 1 0 clear 1 1 toggle bswtrg effect 0 0 none 0 1 set 1 0 clear 1 1 toggle bcpb effect
692 32015a?avr32?02/07 AT32AP7001 33.7.6 tc counter value register register name: cv access type: read-only ? cv: counter value cv contains the counter value in real time. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 cv 76543210 cv
693 32015a?avr32?02/07 AT32AP7001 33.7.7 tc register a register name: ra access type: read-only if wave = 0, read/write if wave = 1 ? ra: register a ra contains the register a value in real time. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ra 76543210 ra
694 32015a?avr32?02/07 AT32AP7001 33.7.8 tc register b register name: rb access type: read-only if wave = 0, read/write if wave = 1 ? rb: register b rb contains the register b value in real time. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rb 76543210 rb
695 32015a?avr32?02/07 AT32AP7001 33.7.9 tc register c register name: rc access type: read/write ? rc: register c rc contains the register c value in real time. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 rc 76543210 rc
696 32015a?avr32?02/07 AT32AP7001 33.7.10 tc status register register name: sr access type: read-only ? covfs: counter overflow status 0 = no counter overflow has occurred since the last read of the status register. 1 = a counter overflow has occurred since the last read of the status register. ? lovrs: load overrun status 0 = load overrun has not occurred since the last read of the status register or wave = 1. 1 = ra or rb have been loaded at least twice without any read of the corresponding register since the last read of the sta- tus register, if wave = 0. ? cpas: ra compare status 0 = ra compare has not occurred since the last read of the status register or wave = 0. 1 = ra compare has occurred since the last read of the status register, if wave = 1. ? cpbs: rb compare status 0 = rb compare has not occurred since the last read of the status register or wave = 0. 1 = rb compare has occurred since the last read of the status register, if wave = 1. ? cpcs: rc compare status 0 = rc compare has not occurred since the last read of the status register. 1 = rc compare has occurred since the last read of the status register. ? ldras: ra loading status 0 = ra load has not occurred si nce the last read of the status register or wave = 1. 1 = ra load has occurred since the last re ad of the status register, if wave = 0. ? ldrbs: rb loading status 0 = rb load has not occurred si nce the last read of the status register or wave = 1. 1 = rb load has occurred since the last re ad of the status register, if wave = 0. ? etrgs: external trigger status 0 = external trigger has not occurred since the last read of the status register. 1 = external trigger has occurred since the last read of the status register. ? clksta: clock enabling status 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ?????mtiobmtioaclksta 15 14 13 12 11 10 9 8 ???????? 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
697 32015a?avr32?02/07 AT32AP7001 0 = clock is disabled. 1 = clock is enabled. ? mtioa: tioa mirror 0 = tioa is low. if wave = 0, this mean s that tioa pin is low. if wave = 1, this means that tioa is driven low. 1 = tioa is high. if wave = 0, this mean s that tioa pin is high. if wave = 1, this means that ti oa is driven high. ? mtiob: tiob mirror 0 = tiob is low. if wave = 0, this mean s that tiob pin is low. if wave = 1, this means that tiob is driven low. 1 = tiob is high. if wave = 0, this mean s that tiob pin is high. if wave = 1, this means that ti ob is driven high.
698 32015a?avr32?02/07 AT32AP7001 33.7.11 tc interrupt enable register register name: ier access type: write-only ? covfs: counter overflow 0 = no effect. 1 = enables the counter overflow interrupt. ? lovrs: load overrun 0 = no effect. 1 = enables the load overrun interrupt. ? cpas: ra compare 0 = no effect. 1 = enables the ra compare interrupt. ? cpbs: rb compare 0 = no effect. 1 = enables the rb compare interrupt. ? cpcs: rc compare 0 = no effect. 1 = enables the rc compare interrupt. ? ldras: ra loading 0 = no effect. 1 = enables the ra load interrupt. ? ldrbs: rb loading 0 = no effect. 1 = enables the rb load interrupt. ? etrgs: external trigger 0 = no effect. 1 = enables the external trigger interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
699 32015a?avr32?02/07 AT32AP7001 33.7.12 tc interrupt disable register register name: idr access type: write-only ? covfs: counter overflow 0 = no effect. 1 = disables the counter overflow interrupt. ? lovrs: load overrun 0 = no effect. 1 = disables the load overru n interrupt (if wave = 0). ? cpas: ra compare 0 = no effect. 1 = disables the ra compare interrupt (if wave = 1). ? cpbs: rb compare 0 = no effect. 1 = disables the rb compare interrupt (if wave = 1). ? cpcs: rc compare 0 = no effect. 1 = disables the rc compare interrupt. ? ldras: ra loading 0 = no effect. 1 = disables the ra load interrupt (if wave = 0). ? ldrbs: rb loading 0 = no effect. 1 = disables the rb load interrupt (if wave = 0). ? etrgs: external trigger 0 = no effect. 1 = disables the external trigger interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
700 32015a?avr32?02/07 AT32AP7001 33.7.13 tc interrupt mask register register name: imr access type: read-only ? covfs: counter overflow 0 = the counter overflow interrupt is disabled. 1 = the counter overflow interrupt is enabled. ? lovrs: load overrun 0 = the load overrun interrupt is disabled. 1 = the load overrun interrupt is enabled. ? cpas: ra compare 0 = the ra compare interrupt is disabled. 1 = the ra compare interrupt is enabled. ? cpbs: rb compare 0 = the rb compare interrupt is disabled. 1 = the rb compare interrupt is enabled. ? cpcs: rc compare 0 = the rc compare interrupt is disabled. 1 = the rc compare interrupt is enabled. ? ldras: ra loading 0 = the load ra interrupt is disabled. 1 = the load ra interrupt is enabled. ? ldrbs: rb loading 0 = the load rb interrupt is disabled. 1 = the load rb interrupt is enabled. ? etrgs: external trigger 0 = the external trigger interrupt is disabled. 1 = the external trigger interrupt is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 etrgs ldrbs ldras cpcs cpbs cpas lovrs covfs
701 32015a?avr32?02/07 AT32AP7001 34. pulse width modulation controller (pwm) rev: 6044e 34.1 features ? 4 channels ? one 20-bit counter per channel ? common clock generator providin g thirteen different clocks ? a modulo n counter providing eleven clocks ? two independent linear dividers working on modulo n counter outputs ? independent channels ? independent enable disable command for each channel ? independent clock selection for each channel ? independent period and duty cycle for each channel ? double buffering of period or duty cycle for each channel ? programmable selection of the output waveform polarity for each channel ? programmable center or left aligne d output waveform for each channel 34.2 description the pwm macrocell controls several cha nnels independently. each channel controls one square output waveform. characteristics of the output waveform such as period, duty-cycle and polarity are configurable through the user interface. each channel selects and uses one of the clocks provided by the clock generator. the cloc k generator provides several clocks resulting from the division of the pwm macrocell master clock. all pwm macrocell accesses are made through registers mapped on the peripheral bus. channels can be synchronized, to generate non overlapped waveforms. all channels integrate a double buffering system in order to prevent an unexpected output waveform while modifying the period or the duty-cycle.
702 32015a?avr32?02/07 AT32AP7001 34.3 block diagram figure 34-1. pulse width modulation controller block diagram 34.4 i/o lines description each channel outputs one waveform on one external i/o line. pwm controller peripheral bus pwmx pwmx pwmx channel update duty cycle counter pwm0 channel pio interrupt controller power manager mck clock generator pb interface interrupt generator clock selector period comparator update duty cycle counter clock selector period comparator pwm0 pwm0 table 34-1. i/o line description name description type pwmx pwm waveform output for channel x output
703 32015a?avr32?02/07 AT32AP7001 34.5 product dependencies 34.5.1 i/o lines the pins used for interfacing the pwm may be multiplexed with pio lines. the programmer must first program the pio controller to assign the desire d pwm pins to their peripheral function. if i/o lines of the pwm are not used by the applicati on, they can be used for other purposes by the pio controller. not all pwm outputs may be enabled. if an application requires only four channels, then only four pio lines will be as signed to pwm outputs. 34.5.2 power management the pwm clock is generated by the power manager. before using the pwm, the programmer must ensure that the twi clock is enabled in the power manager. however, if the application does not require pwm operations, the pwm clock can be stopped when not needed and be restarted later. in this ca se, the pwm will resume its oper ations where it left off. in the pwm description, master clock (mck) is the clock of the peripheral bus to which the pwm is connected. 34.5.3 interrupt sources the pwm interrupt line is connected to the interrupt controller. using the pwm interrupt requires the interrupt controller to be programmed first.
704 32015a?avr32?02/07 AT32AP7001 34.6 functional description the pwm macrocell is primarily composed of a clock generator module and 4 channels. ? clocked by the system clock, mck, the clock generator module provides 13 clocks. ? each channel can independently choose one of the clock generator outputs. ? each channel generates an output waveform with attributes that can be defined independently for each channel through the user interface registers. 34.6.1 pwm clock generator figure 34-2. functional view of the clock generator block diagram caution: before using the pwm macrocell, the programmer must ensure that the pwm clock in the power manager is enabled. the pwm macrocell master clock, mck, is divide d in the clock generator module to provide dif- ferent clocks available for all channels. each channel can independently select one of the divided clocks. modulo n counter mck mck/2 mck/4 mck/16 mck/32 mck/64 mck/8 divider a clka diva pwm_mr mck mck/128 mck/256 mck/512 mck/1024 prea divider b clkb divb pwm_mr preb
705 32015a?avr32?02/07 AT32AP7001 the clock generator is divided in three blocks: ? a modulo n counter whic h provides 11 clocks: f mck , f mck /2, f mck /4, f mck /8, f mck /16, f mck /32, f mck /64, f mck /128, f mck /256, f mck /512, f mck /1024 ? two linear dividers (1, 1/2, 1/3, ... 1/255) that provide two separate clocks: clka and clkb each linear divider can independently divide one of the clocks of the modulo n counter. the selection of the clock to be divided is made ac cording to the prea (preb) field of the pwm mode register (mr). the resulting clock clka (clk b) is the clock selected divided by diva (divb) field value in the pwm mode register (mr). after a reset of the pwm controller, diva (divb) and prea (preb) in the pwm mode register are set to 0. this implies that after reset clka (clkb) are turned off. at reset, all clocks provided by the modulo n counter are turned off except clock ?clk?. this situa- tion is also true when the pwm master cl ock is turned off through the power management controller. 34.6.2 pwm channel 34.6.2.1 block diagram figure 34-3. functional view of the channel block diagram each of the 4 channels is composed of three blocks: ? a clock selector which selects one of the clocks provided by the clock generator described in section 34.6.1 ?pwm clock generator? on page 704 . ? an internal counter clocked by the output of the clock selector. this internal counter is incremented or decremented according to the channel configuration and comparators events. the size of the internal counter is 20 bits. ? a comparator used to generate events according to the internal counter value. it also computes the pwmx output waveform according to the configuration. 34.6.2.2 waveform properties the different properties of output waveforms are: ? the internal clock selection . the internal channel counter is clocked by one of the clocks provided by the clock generator described in the previous section. this channel parameter is defined in the cpre field of the cmrx register. this field is reset at 0. ? the waveform period . this channel parameter is defined in the cprd field of the cprdx register. comparator pwmx output waveform internal counter clock selector inputs from clock generator inputs from peripheral bus channel
706 32015a?avr32?02/07 AT32AP7001 - if the waveform is left aligned, then the output waveform period depends on the counter source clock and can be calculated: by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32 , 64, 128, 256, 512, or 1024), the resulting period formula will be: by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or if the waveform is center aligned then the output waveform period depends on the counter source clock and can be calculated: by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024 ). the resulting period formula will be: by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or ? the waveform duty cycle . this channel parameter is defined in the cdty field of the cdtyx register. if the waveform is left aligned then: if the waveform is center aligned, then: ? the waveform polarity. at the beginning of the period, the signal can be at high or low level. this property is defined in the cpol field of t he cmrx register. by default the signal starts by a low level. ? the waveform alignment . the output waveform can be left or center aligned. center aligned waveforms can be used to generate non overlapped waveforms. this property is defined in the calg field of the cmrx register. the default mode is left aligned. xcprd () mck ------------------------------- crpd diva () mck ------------------------------------------ crpd divab () mck ---------------------------------------------- 2 x cprd () mck ---------------------------------------- - 2 cprd diva () mck --------------------------------------------------- - 2 cprd divb () mck --------------------------------------------------- - duty cycle period 1 fchannel_x_clock cdty ? ? () period ------------------------------------------------------------------------------------------------------- - = duty cycle period 2 ? () 1 fchannel_x_clock cdty ? ? ()) period 2 ? () ---------------------------------------------------------------------------------------------------------------------- - =
707 32015a?avr32?02/07 AT32AP7001 figure 34-4. non overlapped center aligned waveforms note: 1. see figure 34-5 on page 708 for a detailed description of center aligned waveforms. when center aligned, the internal channel count er increases up to cprd and.decreases down to 0. this ends the period. when left aligned, the internal channel counter increases up to cprd and is reset. this ends the period. thus, for the same cprd value, the period for a ce nter aligned channel is twice the period for a left aligned channel. waveforms are fixed at 0 when: ? cdty = cprd and cpol = 0 ? cdty = 0 and cpol = 1 waveforms are fixed at 1 (once the channel is enabled) when: ? cdty = 0 and cpol = 0 ? cdty = cprd and cpol = 1 the waveform polarity must be set before enabling the channel. this immediately affects the channel output level. changes on channel polari ty are not taken into account while the channel is enabled. pwm0 pwm1 period no overlap
708 32015a?avr32?02/07 AT32AP7001 figure 34-5. waveform properties pwm_mckx chidx(pwm_sr) center aligned cprd(pwm_cprdx) cdty(pwm_cdtyx) pwm_ccntx output waveform pwmx cpol(pwm_cmrx) = 0 output waveform pwmx cpol(pwm_cmrx) = 1 chidx(pwm_isr) left aligned cprd(pwm_cprdx) cdty(pwm_cdtyx) pwm_ccntx output waveform pwmx cpol(pwm_cmrx) = 0 output waveform pwmx cpol(pwm_cmrx) = 1 chidx(pwm_isr) calg(pwm_cmrx) = 0 calg(pwm_cmrx) = 1 period period chidx(pwm_ena) chidx(pwm_dis)
709 32015a?avr32?02/07 AT32AP7001 34.6.3 pwm controller operations 34.6.3.1 initialization before enabling the output channel, this chann el must have been configured by the software application: ? configuration of the clock generator if diva and divb are required ? selection of the clock for each channel (cpre field in the cmrx register) ? configuration of the waveform alignment for each channel (calg field in the cmrx register) ? configuration of the period for each channel (cprd in the cprdx register). writing in cprdx register is possible while the channel is disabl ed. after validation of the channel, the user must use cupdx register to update cprdx as explained below. ? configuration of the duty cycle fo r each channel (cdty in the cdtyx register). writing in cdtyx register is possible while the channel is disabled. after validation of the channel, the user must use cupdx register to update cdtyx as explained below. ? configuration of the output waveform polarity for each channel (cpol in the cmrx register) ? enable interrupts (writing chidx in the ier register) ? enable the pwm channel (writing chidx in the ena register) it is possible to synchronize different channels by enabling them at the same time by means of writing simultaneously several chi dx bits in the ena register. in such a situation, all channels may have the same clock selector configuration and the same period specified. 34.6.3.2 source clock selection criteria the large number of source clocks can make selection difficult. the relationship between the value in the period register (cprdx) and the duty cycle register (cdtyx) can help the user in choosing. the event number written in the period register gives the pwm accuracy. the duty cycle quantum cannot be lower than 1/cprdx value. the higher the value of cprdx, the greater the pwm accuracy. for example, if the user sets 15 (in decimal) in cprdx, the user is able to set a value between 1 up to 14 in cdtyx register. the resulting duty cycle quantum cannot be lower than 1/15 of the pwm period. 34.6.3.3 changing the duty cycle or the period it is possible to modulate the output waveform duty cycle or period. to prevent unexpected output waveform, the user must use the update register (pwm_cupdx) to change waveform parameters while the channel is still enabled. the user can write a new period value or duty cycle value in the update re gister (cupdx). this register holds the new value until the end of the current cycle and updates the value for the next cycle. depending on the cpd field in the cmrx register, cupdx either updates cprdx or cdtyx. note that even if the update register is used, the period must not be smaller than the duty cycle.
710 32015a?avr32?02/07 AT32AP7001 figure 34-6. synchronized period or duty cycle update to prevent overwriting the cupdx by software, t he user can use status events in order to syn- chronize his software. two methods are possible. in both, the user must enable the dedicated interrupt in ier at pwm controller level. the first method (polling method) consists of r eading the relevant status bit in isr register according to the enabled channel(s). see figure 34-7 . the second method uses an interrupt service routine associated with the pwm channel. note: reading the isr register automatically clears chidx flags. figure 34-7. polling method note: polarity and alignment can be modified only when the channel is disabled. pwm_cupdx value pwm_cprdx pwm_cdtyx end of cycle pwm_cmrx. cpd user's writing 1 0 writing in pwm_cupdx the last write has been taken into account chidx = 1 writing in cpd field update of the period or duty cycle pwm_isr read acknowledgement and clear previous register state yes
711 32015a?avr32?02/07 AT32AP7001 34.6.3.4 interrupts depending on the interrupt mask in the imr register, an interrupt is generated at the end of the corresponding channel period. the interrupt remains active until a read operation in the isr reg- ister occurs. a channel interrupt is enabled by setting the corresponding bit in the ier register. a channel interrupt is disabled by setting the corresponding bit in the idr register.
712 32015a?avr32?02/07 AT32AP7001 34.7 pulse width modulation (pwm ) controller user interface 34.7.1 register mapping table 34-2. pwm controller registers offset register name access peripheral reset value 0x00 pwm mode register mr read/write 0 0x04 pwm enable register ena write-only - 0x08 pwm disable register dis write-only - 0x0c pwm status register sr read-only 0 0x10 pwm interrupt enable register ier write-only - 0x14 pwm interrupt disable register idr write-only - 0x18 pwm interrupt mask register imr read-only 0 0x1c pwm interrupt status register isr read-only 0 0x4c - 0xf8 reserved ? ? ? 0x4c - 0xfc reserved ? ? ? 0x100 - 0x1fc reserved 0x200 channel 0 mode register cmr0 read/write 0x0 0x204 channel 0 duty cycle register cdty0 read/write 0x0 0x208 channel 0 period register cprd0 read/write 0x0 0x20c channel 0 counter register ccnt0 read-only 0x0 0x210 channel 0 update register cupd0 write-only - ... reserved 0x220 channel 1 mode register cmr1 read/write 0x0 0x224 channel 1 duty cycle register cdty1 read/write 0x0 0x228 channel 1 period register cprd1 read/write 0x0 0x22c channel 1 counter register ccnt1 read-only 0x0 0x230 channel 1 update register cupd1 write-only - ... ... ... ... ...
713 32015a?avr32?02/07 AT32AP7001 34.7.2 pwm mode register register name: mr access type: read/write ? diva, divb: clka, clkb divide factor ? prea, preb 31 30 29 28 27 26 25 24 ???? preb 23 22 21 20 19 18 17 16 divb 15 14 13 12 11 10 9 8 ???? prea 76543210 diva diva, divb clka, clkb 0 clka, clkb clock is turned off 1 clka, clkb clock is clock selected by prea, preb 2-255 clka, clkb clock is clock selected by prea, preb divided by diva, divb factor. prea, preb divider input clock 0000mck. 0001mck/2 0010mck/4 0011mck/8 0100mck/16 0101mck/32 0110mck/64 0111mck/128 1000mck/256 1001mck/512 1010mck/ 1024 other reserved
714 32015a?avr32?02/07 AT32AP7001 34.7.3 pwm enable register register name: ena access type: write-only ? chidx: channel id 0 = no effect. 1 = enable pwm output for channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
715 32015a?avr32?02/07 AT32AP7001 34.7.4 pwm disable register register name: dis access type: write-only ? chidx: channel id 0 = no effect. 1 = disable pwm output for channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
716 32015a?avr32?02/07 AT32AP7001 34.7.5 pwm status register register name: sr access type: read-only ? chidx: channel id 0 = pwm output for channel x is disabled. 1 = pwm output for channel x is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
717 32015a?avr32?02/07 AT32AP7001 34.7.6 pwm interrupt enable register register name: ier access type: write-only ? chidx: channel id. 0 = no effect. 1 = enable interrupt for pwm channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
718 32015a?avr32?02/07 AT32AP7001 34.7.7 pwm interrupt disable register register name: idr access type: write-only ? chidx: channel id. 0 = no effect. 1 = disable interrupt for pwm channel x. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
719 32015a?avr32?02/07 AT32AP7001 34.7.8 pwm interrupt mask register register name: imr access type: read-only ? chidx: channel id. 0 = interrupt for pwm channel x is disabled. 1 = interrupt for pwm channel x is enabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
720 32015a?avr32?02/07 AT32AP7001 34.7.9 pwm interrupt status register register name: isr access type: read-only ? chidx: channel id 0 = no new channel period since the last read of the isr register. 1 = at least one new channel period since the last read of the isr register. note: reading isr automatically clears chidx flags. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 ????chid3chid2chid1chid0
721 32015a?avr32?02/07 AT32AP7001 34.7.10 pwm channel mode register register name: cmrx access type: read/write ? cpre: channel pre-scaler ? calg: channel alignment 0 = the period is left aligned. 1 = the period is center aligned. ? cpol: channel polarity 0 = the output waveform starts at a low level. 1 = the output waveform starts at a high level. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ?????cpdcpolcalg 76543210 ???? cpre cpre channel pre-scaler 0000mck 0001mck/2 0010mck/4 0011mck/8 0100mck/16 0101mck/32 0110mck/64 0111mck/128 1000mck/256 1001mck/512 1 0 1 0 mck/1024 1011clka 1100clkb other reserved
722 32015a?avr32?02/07 AT32AP7001 ? cpd: channel update period 0 = writing to the cupdx will modify the duty cycle at the next period start event. 1 = writing to the cupdx will modify the period at the next period start event.
723 32015a?avr32?02/07 AT32AP7001 34.7.11 pwm channel duty cycle register register name: cdty x access type: read/write only the first 20 bits (internal ch annel counter size) are significant. ? cdty: channel duty cycle defines the waveform duty cycle. this value must be defined between 0 and cprd (cprx). 31 30 29 28 27 26 25 24 cdty 23 22 21 20 19 18 17 16 cdty 15 14 13 12 11 10 9 8 cdty 76543210 cdty
724 32015a?avr32?02/07 AT32AP7001 34.7.12 pwm channel period register register name: cprdx access type: read/write only the first 20 bits (internal ch annel counter size) are significant. ? cprd: channel period if the waveform is left-aligned, then the output waveform period depends on the counter source clock and can be calculated: ? by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). the resultin g period formula will be: ? by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or if the waveform is center-aligned, then the output waveform period depends on the counter source clock and can be calculated: ? by using the master clock (mck) divided by an x given prescaler value (with x being 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, or 1024). the resultin g period formula will be: ? by using a master clock divided by one of both diva or divb divider, the formula becomes, respectively: or 31 30 29 28 27 26 25 24 cprd 23 22 21 20 19 18 17 16 cprd 15 14 13 12 11 10 9 8 cprd 76543210 cprd xcprd () mck ------------------------------- crpd diva () mck ------------------------------------------ crpd divab () mck ---------------------------------------------- 2 x cprd () mck ---------------------------------------- - 2 cprd diva () mck --------------------------------------------------- - 2 cprd divb () mck --------------------------------------------------- -
725 32015a?avr32?02/07 AT32AP7001 34.7.13 pwm channel counter register register name: ccntx access type: read-only ? cnt: channel counter register internal counter value. this register is reset when: ? the channel is enabled (writing chidx in the ena register). ? the counter reaches cprd value defined in the cp rdx register if the wa veform is left aligned. 31 30 29 28 27 26 25 24 cnt 23 22 21 20 19 18 17 16 cnt 15 14 13 12 11 10 9 8 cnt 76543210 cnt
726 32015a?avr32?02/07 AT32AP7001 34.7.14 pwm channel update register register name: cupdx access type: write-only this register acts as a double buffer for the period or the duty cycle. this prevents an unexpected waveform when modify- ing the waveform period or duty-cycle. only the first 20 bits (internal chan nel counter size) are significant. 31 30 29 28 27 26 25 24 cupd 23 22 21 20 19 18 17 16 cupd 15 14 13 12 11 10 9 8 cupd 76543210 cupd cpd (cmrx register) 0 the duty-cycle (cdtc in the cdrx register) is u pdated with the cupd value at the beginning of the next period. 1 the period (cprd in the cprx register) is upd ated with the cupd value at the beginning of the next period.
727 32015a?avr32?02/07 AT32AP7001 35. image sensor interface (isi) rev: 0.0.5.0 35.1 features ? itu-r bt. 601/656 8-bit mode external inte rface support ? supports up to 12-bit grayscale cmos sensors ? support for itu-r bt.656-4 sa v and eav synchronization ? vertical and horizontal re solutions up to 2048 x 2048 ? preview path up to 640*480 ? 128 bytes fifo on codec path ? 128 bytes fifo on preview path ? support for packed data formatting for ycbcr 4:2:2 formats ? preview scaler to genera te smaller size image ? programmable frame capture rate ? vga, qvga, cif, qcif supported for lcd preview ? custom formats with horizontal and vertical preview size as mult iples of 16 also supported for lcd preview 35.2 overview the image sensor interface (isi) connects a cmos-type image sensor to the processor and provides image capture in various formats. it does data conversion, if necessary, before the stor- age in memory through dma. the isi supports color cmos image sensor and grayscale image sensors with a reduced set of functionalities. in grayscale mode, the data stream is stored in memory without any processing and so is not compatible with th e lcd controller. internal fifos on the preview and codec paths are used to store the incoming data. the rgb output on the preview path is compatible with the lcd controller. this module outputs the data in rgb format (lcd compatible) and has scaling capabilities to make it compliant to the lcd display resolution (see table 35-3 on page 730 ). several input formats such as preprocessed rgb or ycbcr are supported through the data bus interface. it supports two modes of synchronization: 1. the hardware with vsync and hsync signals 2. the international telecommunication union recommendation itu-r bt.656-4 start-of- active-video (sav) and end-of-active-video (eav) synchronization sequence. using eav/sav for synchronization reduces th e pin count (vsync, hsync not used). the polarity of the synchronization pulse is pr ogrammable to comply with the sensor signals. table 35-1. i/o description signal dir description vsync in vertical synchronization hsync in horizontal synchronization
728 32015a?avr32?02/07 AT32AP7001 figure 35-1. isi connection example 35.3 block diagram figure 35-2. image sensor interface block diagram 35.4 functional description the image sensor interface (isi) supports direct connection to the international telecommuni- cation union recommendation itu-r bt. 601/656 8-bit mode compliant sensors and up to 12- bit grayscale sensors. it receives the image dat a stream from the image sensor on the 12-bit data bus. data[11..0] in sensor pixel data mck out master clock provided to the image sensor pck in pixel clock provided by the image sensor table 35-1. i/o description image sensor image sensor interface data[11..0] isi_data[11..0] clk isi_mck pclk isi_pck vsync hsync isi_vsync isi_hsync timing signals interface ccir-656 embedded timing decoder(sav/eav) pixel sampling module clipping + color conversion ycc to rgb 2-d image scaler pixel formatter rx direct display fifo core video arbiter camera hsb master interface pb interface camera interrupt controller config registers clipping + color conversion rgb to ycc rx direct capture fifo scatter mode support packed formatter frame rate ycbcr 4:2:2 8:8:8 5:6:5 rgb cmos sensor pixel input up to 12 bit hsync/len vsync/fen cmos sensor pixel clock input pixel clock domain hsb clock domain pb clock domain from rx buffers camera interrupt request line codec_on hsb bus pb bus
729 32015a?avr32?02/07 AT32AP7001 this module receives up to 12 bits for data, the ho rizontal and vertical sy nchronizations and the pixel clock. the reduced pin count alternative for synchronization is supported for sensors that embed sav (start of active vide o) and eav (end of active video) delimiters in the data stream. the image sensor interface interrupt line is gener ally connected to the interrupt controller and can trigger an interrupt at the beginning of each frame and at the end of a dma frame transfer. if the sav/eav synchronization is us ed, an interrupt ca n be triggered on each delimiter event. for 8-bit color sensors, the data stream received can be in several possible formats: ycbcr 4:2:2, rgb 8:8:8, rgb 5:6:5 and may be processed before the storage in memory. the data stream may be sent on both preview path and codec path if the bit codec_on in the cr1 is one. to optimize the bandwidth, the codec path should be enabled only when a capture is required. in grayscale mode, the input data stream is stored in memory without any processing. the 12-bit data, which represent the grayscale level for the pixel, is stored in memory one or two pixels per word, depending on the gs_mode bit in the cr2 register. the codec datapath is not available when grayscale image is selected. a frame rate counter allows users to capture all frames or 1 out of every 2 to 8 frames. 35.4.1 data timing the two data timings using hori zontal and vertical synchroni zation and eav/sav sequence syn- chronization are shown in figure 35-3 and figure 35-4 . in the vsync/hsync synchronization, the valid da ta is captured with the active edge of the pixel clock (pck), after sfd lines of vertical blanking and sld pixel cl ock periods delay pro- grammed in the control register. the itu-rbt.656-4 defines the functional timing for an 8-bit wide interface. there are two timing reference signals, one at the beginning of each video data block sav (0xff000080) and one at the end of each video data block eav(0xff00009d). only data sent between eav and sav is capt ured. horizontal blanking and vert ical blanking are ignored. use of the sav and eav synchronization eliminates t he vsync and hsync signals from the inter- face, thereby reducing the pin count. in order to retrieve both frame and line synchronization properly, at least one line of vertical blanking is mandatory. figure 35-3. hsync and vsync synchronization isi_vsync isi_hsync isi_pck frame 1 line ycby crycb y crycby cr data[7..0]
730 32015a?avr32?02/07 AT32AP7001 figure 35-4. sav and eav sequence synchronization 35.4.2 data ordering the rgb color space format is required for viewing images on a display screen preview, and the ycbcr color space format is required for encoding. all the sensors do not output the ycbcr or rgb components in the same order. the isi allows the user to program the same component order as the sensor, reducing software treatments to restore the right format. isii_pck cr y cb y cr y y cr y cb ff 00 data[7..0] ff 00 00 80 y cb y 00 9d sav eav active video table 35-2. data ordering in ycbcr mode mode byte 0 byte 1 byte 2 byte 3 default cb(i) y(i) cr(i) y(i+1) mode1 cr(i) y(i) cb(i) y(i+1) mode2 y(i) cb(i) y(i+1) cr(i) mode3 y(i) cr(i) y(i+1) cb(i) table 35-3. rgb format in default mode, rgb_cfg = 00, no swap mode byte d7 d6 d5 d4 d3 d2 d1 d0 rgb 8:8:8 byte 0 r7(i) r6(i) r5(i) r4(i) r3(i) r2(i) r1(i) r0(i) byte 1 g7(i) g6(i) g5(i) g4(i) g3(i) g2(i) g1(i) g0(i) byte 2 b7(i) b6(i) b5(i) b4 (i) b3(i) b2(i) b1(i) b0(i) byte 3 r7(i+1) r6(i+1) r5(i+1) r4(i +1) r3(i+1) r2(i+1) r1(i+1) r0(i+1) rgb 5:6:5 byte 0 r4(i) r3(i) r2(i) r1(i) r0(i) g5(i) g4(i) g3(i) byte 1 g2(i) g1(i) g0(i) b4(i) b3(i) b2(i) b1(i) b0(i) byte 2 r4(i+1) r3(i+1) r2(i+1) r1(i+1) r0(i+1) g5(i+1) g4(i+1) g3(i+1) byte 3 g2(i+1) g1(i+1) g0(i+1) b4(i+1) b3i+1) b2(i+1) b1(i+1) b0(i+1) table 35-4. rgb format, rgb_cfg = 10 (mode 2), no swap mode byte d7 d6 d5 d4 d3 d2 d1 d0 rgb 5:6:5 byte 0 g2(i) g1(i) g0(i) r4(i) r3(i) r2(i) r1(i) r0(i) byte 1 b4(i) b3(i) b2(i) b1 (i) b0(i) g5(i) g4(i) g3(i) byte 2 g2(i+1) g1(i+1) g0(i+1) r4(i+1) r3(i+1) r2(i+1) r1(i+1) r0(i+1) byte 3 b4(i+1) b3(i+1) b2(i+1) b1(i+1) b0(i+1) g5(i+1) g4(i+1) g3(i+1)
731 32015a?avr32?02/07 AT32AP7001 the rgb 5:6:5 input format is processed to be displayed as rgb 5:5:5 format, compliant with the 16-bit mode of the lcd controller. 35.4.3 clocks the sensor master clock (mck) can be generated either by the power manager through a pro- grammable clock output or by an extern al oscillator connec ted to the sensor. none of the sensors embeds a power management controller, so providing the clock by the power manager is a simple and efficient way to control power consumption of the system. care must be taken when programming the system clock. the isi has two clock domains, the system bus clock and the pixel clock provided by sensor. the two clock domains are not syn- chronized, but the system clock must be faster than pixel clock. 35.4.4 preview path 35.4.4.1 scaling, deci mation (subsampling) this module resizes captured 8-bit color sensor images to fit the lcd display format. the resize module performs only downscaling. the same ra tio is applied for both horizontal and vertical resize, then a fractional decimation algorithm is applied. the decimation factor is a multiple of 1/16 and values 0 to 15 are forbidden. table 35-5. rgb format in default mode, rgb_cfg = 00, swap activated mode byte d7 d6 d5 d4 d3 d2 d1 d0 rgb 8:8:8 byte 0 r0(i) r1(i) r2(i) r3(i) r4(i) r5(i) r6(i) r7(i) byte 1 g0(i) g1(i) g2(i) g3(i) g4(i) g5(i) g6(i) g7(i) byte 2 b0(i) b1(i) b2(i) b3 (i) b4(i) b5(i) b6(i) b7(i) byte 3 r0(i+1) r1(i+1) r2(i+1) r3(i +1) r4(i+1) r5(i+1) r6(i+1) r7(i+1) rgb 5:6:5 byte 0 g3(i) g4(i) g5(i) r0(i) r1(i) r2(i) r3(i) r4(i) byte 1 b0(i) b1(i) b2(i) b3 (i) b4(i) g0(i) g1(i) g2(i) byte 2 g3(i+1) g4(i+1) g5(i+1) r0(i+1) r1(i+1) r2(i+1) r3(i+1) r4(i+1) byte 3 b0(i+1) b1(i+1) b2(i+1) b3(i+1) b4(i+1) g0(i+1) g1(i+1) g2(i+1) table 35-6. decimation factor dec value 0->15 16 17 18 19 ... 124 125 126 127 dec factor x 1 1.063 1.125 1.188 ... 7.750 7.813 7.875 7.938 table 35-7. decimation and scaler offset values input output 352*288 640*480 800*600 1280*1024 1600*1200 2048*1536 vga 640*480 fna1620324051
732 32015a?avr32?02/07 AT32AP7001 example: input 1280*1024 output=640*480 hratio = 1280/640 =2 vratio = 1024/480 =2.1333 the decimation factor is 2 so 32/16. figure 35-5. resize examples 35.4.4.2 color space conversion this module converts ycrcb or yuv pixels to rg b color space. clipping is performed to ensure that the samples value do not exceed the allowable range. the conversion matrix is defined below: example of programmable value to convert ycrcb to rgb: qvga 320*240 f1632406480102 cif 352*288 f162633566685 qcif 176*144 f 16 53 66 113 133 170 table 35-7. decimation and scaler offset values 1280 1024 480 640 32/16 decimation 1280 1024 288 352 56/16 decimation r g b c 0 0 c 1 c 0 c 2 ? c 3 ? c 0 c 4 0 yy off ? c b c boff ? c r c roff ? =
733 32015a?avr32?02/07 AT32AP7001 an example of programmable value to convert from yuv to rgb: 35.4.4.3 memory interface preview datapath contains a data formatter that converts 8:8:8 pixel to rgb 5:5:5 format compli- ant with 16-bit format of the lcd controller. in general, when converting from a color channel with more bits to one with fewer bits, formatter module discards the lower-order bits. example: converting from rgb 8:8:8 to rgb 5:6:5, it discards the three lsbs from the red and blue chan- nels, and two lsbs from the green channel. when grayscale mode is enabled, two memory format are supported. one mode supports 2 pixels per word, and the other mode supports 1 pixel per word. 35.4.4.4 fifo and dma features both preview and codec datapaths contain fifos, asynchronous buffers that are used to safely transfer formatted pixels from pixel clock domain to high speed bus (hsb) clock domain. a video arbiter is used to manage fifo thresholds and triggers a relevant dma request through the hsb master interface. thus, depending on fifo state, a specified length burst is asserted. regarding hsb master interface, it supports scatter dma mode through linked list operation. this mode of operation improves flexibility of image buffer location and allows the user to allo- cate two or more frame buffers. the destination frame buffers are defined by a series of frame buffer descriptors (fbd). each fbd controls the transfer of one entire frame and then optionally loads a further fbd to switch the dma operation at another frame buffer address. the fbd is defined by a series of two words. the first one defines the current frame buffer address, and the second defines the next fbd memory location. this dma transfer mode is only available for pre- view datapath and is configured in the ppfbd register that indicates the memory location of the first fbd. the primary fbd is programmed into the camera interface controller. the data to be transferred described by an fbd requires several burst access. in the example below, the use of 2 ping- pong frame buffers is described. r 1,164 y 16 ? () ? 1,596 c r 128 ? () ? + = g 1,164 y 16 ? () 0,813 c r 128 ? () ? ? 0,392 c b 128 ? () ? ? ? = b 1,164 y 16 ? () ? 2,107 c b 128 ? () ? + = ? ? ? ? ? ry 1,596 v ? + = gy 0,394 u ? ? 0,436 v ? ? = by 2,032 u ? + = ? ? ? ? ? table 35-8. grayscale memory mapping configuration for 12-bit data gs_mode data[31:24] data[23:16] data[15:8] data[7:0] 0 p_0[11:4] p_0[3:0], 0000 p_1[11:4] p_1[3:0], 0000 1 p_0[11:4] p_0[3:0], 0000 0 0
734 32015a?avr32?02/07 AT32AP7001 35.4.4.5 example the first fbd, stored at address 0x30000, defines the location of the first frame buffer. destination address: frame buffer id0 0x02a000 next fbd address: 0x30010 second fbd, stored at address 0x30010, defines the location of the second frame buffer. destination address: frame buffer id1 0x3a000 transfer width: 32 bit next fbd address: 0x30000, wrapping to first fbd. using this technique, several frame buffers can be configured through the linked list. figure 35-6 illustrates a typical three frame bu ffer application. frame n is ma pped to frame buffer 0, frame n+1 is mapped to frame buffer 1, frame n+2 is mapped to frame buffer 2, further frames wrap. a codec request occurs, and the full-size 4:2:2 encoded frame is stored in a dedicated memory space. figure 35-6. three frame buffers application and memory mapping frame n frame n+1 frame n+2 frame n-1 frame n+3 frame n+4 frame buffer 0 frame buffer 1 frame buffer 3 4:2:2 image full roi isi config space codec request codec done lcd memory space
735 32015a?avr32?02/07 AT32AP7001 35.4.5 codec path 35.4.5.1 color space conversion depending on user selection, this module can be bypassed so that input ycrcb stream is directly connected to the format converter module. if the rgb input stream is selected, this mod- ule converts rgb to ycrcb color sp ace with the formulas given below: an example of coefficients are given below: 35.4.5.2 memory interface dedicated fifo are used to support packed memory mapping. ycrcb pixel components are sent in a single 32-bit word in a contiguous space (packed). data is stored in the order of natural scan lines. planar mode is not supported. 35.4.5.3 dma features unlike preview datapath, codec datapath dma mode does not support linked list operation. only the codec_dma_addr register is used to configure the frame buffer base address. y c r c b c 0 c 1 c 2 c 3 c ? 4 c ? 5 c ? 6 c ? 7 c 8 r g b y off cr off cb off + = y 0,257 r ? 0,504 g 0,098 b 16 + ? + ? + = c r 0,439 r ? 0,368 g ? ? 0,071 b 128 + ? ? = c b 0,148 r ? ? 0,291 g 0,439 b 128 + ? + ? ? = ? ? ? ? ?
736 32015a?avr32?02/07 AT32AP7001 35.5 image sensor interface (isi) user interface table 35-9. isi registers offset register name register access reset value 0x00 isi control 1 register cr1 read/write 0x00000002 0x04 isi control 2 register cr2 read/write 0x00000000 0x08 isi status register sr read 0x00000000 0x0c isi interrupt enable register ier write 0x00000000 0x10 isi interrupt disable register idr write 0x00000000 0x14 isi interrupt mask register imr read 0x00000000 0x18 reserved - - - 0x1c reserved - - - 0x20 isi preview size register psize read/write 0x00000000 0x24 isi preview decimation factor register pdecf read/write 0x00000010 0x28 isi preview primary fbd register ppfbd read/write 0x00000000 0x2c isi codec dma base address register cdba read/write 0x00000000 0x30 isi csc ycrcb to rgb set 0 register y2r_set0 read/write 0x6832cc95 0x34 isi csc ycrcb to rgb set 1 register y2r_set1 read/write 0x00007102 0x38 isi csc rgb to ycrcb set 0 register r2y_set0 read/write 0x01324145 0x3c isi csc rgb to ycrcb set 1 register r2y_set1 read/write 0x01245e38 0x40 isi csc rgb to ycrcb set 2 register r2y_set2 read/write 0x01384a4b 0x44-0xfc reserved ? ? ?
737 32015a?avr32?02/07 AT32AP7001 35.5.1 isi control 1 register register name: cr1 access type: read/write reset value: 0x00000002 ? rst: image sensor interface reset 0: no action 1: resets the image sensor interface. ? dis: image sensor disable: 0: enable the image sensor interface. 1: finish capturing the current frame and then shut down the module. ? hsync_pol: horizontal synchronization polarity 0: hsync active high 1: hsync active low ? vsync_pol: vertical synchronization polarity 0: vsync active high 1: vsync active low ? pixclk_pol: pixel clock polarity 0: data is sampled on rising edge of pixel clock 1: data is sampled on fa lling edge of pixel clock ? emb_sync: embedded synchronization 0: synchronization by hsync, vsync 1: synchronization by embedded synchronization sequence sav/eav ? crc_sync: embedded synchronization 0: no crc correction is performed on embedded synchronization 1: crc correction is performed. if the correction is not possib le, the current frame is disc arded and the crc_err is set in the status register. ? frate: frame rate [0..7] 0: all the frames are captured, else one frame every frate+1 is captured. 31 30 29 28 27 26 25 24 sfd 23 22 21 20 19 18 17 16 sld 15 14 13 12 11 10 9 8 codec_en thmask full - frate 76543210 crc_sync emb_sync - pixclk_pol vsync_pol hsync_pol dis rst
738 32015a?avr32?02/07 AT32AP7001 ? full: full mode is allowed 0: codec and preview datapaths are not working simultaneously 1: both codec and preview datapaths are working simultaneously ? thmask: threshold mask 0: 4, 8 and 16 hsb bursts are allowed 1: 8 and 16 hsb bursts are allowed 2: only 16 hsb bursts are allowed ? codec_en: enable the codec path enable bit this bit always read as zero 0: the codec path is disabled 1: the codec path is enabled and the next frame is captured ? sld: start of line delay sld pixel clock periods to wait before the beginning of a line. ? sfd: start of frame delay sfd lines are skipped at the beginning of the frame.
739 32015a?avr32?02/07 AT32AP7001 35.5.2 isi control 2 register register name: cr2 access type: read/write reset value: 0x0 ? im_vsize: vertical size of the image sensor [0..2047] vertical size = im_vsize + 1 ?gs_mode 0: 2 pixels per word 1: 1 pixel per word ? rgb_mode: rgb input mode 0: rgb 8:8:8 24 bits 1: rgb 5:6:5 16 bits ? grayscale 0: grayscale mode is disabled 1: input image is assumed to be grayscale coded ?rgb_swap 0: d7 -> r7 1: d0 -> r7 the rgb_swap has no effect when the grayscale mode is enabled. ? col_space: color space for the image data 0: ycbcr 1: rgb ? im_hsize: horizontal size of the image sensor [0..2047] horizontal size = im_hsize + 1 31 30 29 28 27 26 25 24 rgb_cfg ycc_swap - im_hsize 23 22 21 20 19 18 17 16 im_hsize 15 14 13 12 11 10 9 8 col_space rgb_swap grayscale rgb_mode gs_mode im_vsize 76543210 im_vsize
740 32015a?avr32?02/07 AT32AP7001 ? ycc_swap: defines the ycc image data ? rgb_cfg: defines rgb pattern when rgb_mode is set to 1 if rgb_mode is set to rgb 8:8:8, th en rgb_cfg = 0 implies rgb color sequen ce, else it implies bgr color sequence. ycc_swap byte 0 byte 1 byte 2 byte 3 00: default cb(i) y(i) cr(i) y(i+1) 01: mode1 cr(i) y(i) cb(i) y(i+1) 10: mode2 y(i) cb(i) y(i+1) cr(i) 11: mode3 y(i) cr(i) y(i+1) cb(i) rgb_cfg byte 0 byte 1 byte 2 byte 3 00: default r/g(msb) g(lsb)/b r/g(msb) g(lsb)/b 01: mode1 b/g(msb) g(lsb)/r b/g(msb) g(lsb)/r 10: mode2 g(lsb)/r b/g (msb) g(lsb)/r b/g(msb) 11: mode3 g(lsb)/b r/g(msb) g(lsb)/b r/g(msb)
741 32015a?avr32?02/07 AT32AP7001 35.5.3 isi status register register name: sr access type: read reset value: 0x0 ? sof: start of frame 0: no start of frame has been detected. 1: a start of frame has been detected. ? dis: image sensor interface disable 0: the image sensor interface is enabled. 1: the image sensor in terface is disabled an d stops capturing data. the dma cont roller and the core can still read the fifos. ? softrst: software reset 0: software reset not asserted or not completed 1: software reset has completed successfully ? cdc_stat: codec request status 0: codec request has been asserted 1: codec request has been serviced ? crc_err: crc synchronization error 0: no crc error in the embedd ed synchronization frame (sav/eav) 1: the crc_sync is enabled in the control register and an error has been detected and not corrected. the frame is dis- carded and the isi waits for a new one. ? fo_c_ovf: fifo codec overflow 0: no overflow 1: an overrun condition has occurred in input fifo on the codec path. the overrun happens when the fifo is full and an attempt is made to write a new sample to the fifo. ? fo_p_ovf: fifo preview overflow 0: no overflow 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????fr_ovrfo_c_emp 76543210 fo_p_emp fo_p_ovf fo_c_ovf crc_err cdc_stat softrst dis sof
742 32015a?avr32?02/07 AT32AP7001 1: an overrun condition has occurred in input fifo on the preview path. the overrun happens when the fifo is full and an attempt is made to write a new sample to the fifo. ? fo_p_emp 0:the dma has not finished transferring all the contents of the preview fifo. 1:the dma has finished transferring all the contents of the preview fifo. ?fo_c_emp 0: the dma has not finished transferring all the contents of the codec fifo. 1: the dma has finished transferring all the contents of the codec fifo. ? fr_ovr: frame overrun 0: no frame overrun. 1: frame overrun, the current frame is being skipped because a vsync signal has been detected while flushing fifos.
743 32015a?avr32?02/07 AT32AP7001 35.5.4 interrupt enable register register name: ier access type: write reset value: 0x0 ? sof: start of frame 1: enables the start of frame interrupt. ? dis: image sensor interface disable 1: enables the dis interrupt. ? softrst: soft reset 1: enables the soft reset completion interrupt. ? crc_err: crc synchronization error 1: enables the crc_sync interrupt. ? fo_c_ovf: fifo codec overflow 1: enables the codec fifo overflow interrupt. ? fo_p_ovf: fifo preview overflow 1: enables the preview fifo overflow interrupt. ? fo_p_emp 1: enables the preview fifo empty interrupt. ?fo_c_emp 1: enables the codec fifo empty interrupt. ? fr_ovr: frame overrun 1: enables the frame overrun interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????fr_ovrfo_c_emp 76543210 fo_p_emp fo_p_ovf fo_c_o vf crc_err ? softrst dis sof
744 32015a?avr32?02/07 AT32AP7001 35.5.5 isi interrupt disable register register name: idr access type: write reset value: 0x0 ? sof: start of frame 1: disables the start of frame interrupt. ? dis: image sensor interface disable 1: disables the dis interrupt. ?softrst 1: disables the soft reset completion interrupt. ? crc_err: crc synchronization error 1: disables the crc_sync interrupt. ? fo_c_ovf: fifo codec overflow 1: disables the codec fifo overflow interrupt. ? fo_p_ovf: fifo preview overflow 1: disables the preview fifo overflow interrupt. ? fo_p_emp 1: disables the preview fifo empty interrupt. ?fo_c_emp 1: disables the codec fifo empty interrupt. ? fr_ovr: frame overrun 1: disables frame overrun interrupt. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????fr_ovrfo_c_emp 76543210 fo_p_emp fo_p_ovf fo_c_o vf crc_err ? softrst dis sof
745 32015a?avr32?02/07 AT32AP7001 35.5.6 isi interrupt mask register register name: imr access type: read reset value: 0x0 ? sof: start of frame 0: the start of frame interrupt is disabled. 1: the start of frame interrupt is enabled. ? dis: image sensor interface disable 0: the dis interrupt is disabled. 1: the dis interrupt is enabled. ?softrst 0: the soft reset completion interrupt is enabled. 1: the soft reset completion interrupt is disabled. ? crc_err: crc synchronization error 0: the crc_sync interrupt is disabled. 1: the crc_sync interrupt is enabled. ? fo_c_ovf: fifo codec overflow 0: the codec fifo overflow interrupt is disabled. 1: the codec fifo overflow interrupt is enabled. ? fo_p_ovf: fifo preview overflow 0: the preview fifo overflow interrupt is disabled. 1: the preview fifo overflow interrupt is enabled. ? fo_p_emp 0: the preview fifo empty interrupt is disabled. 1: the preview fifo empty interrupt is enabled. ?fo_c_emp 0: the codec fifo empty interrupt is disabled. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ??????fr_ovrfo_c_emp 76543210 fo_p_emp fo_p_ovf fo_c_o vf crc_err ? softrst dis sof
746 32015a?avr32?02/07 AT32AP7001 1: the codec fifo empty interrupt is enabled. ? fr_ovr: frame overrun 0: the frame overrun interrupt is disabled. 1: the frame overrun interrupt is enabled.
747 32015a?avr32?02/07 AT32AP7001 35.5.7 isi preview size register register name: psize access type: read/write reset value: 0x0 ? prev_vsize: vertical size for the preview path vertical preview size = prev_vsize + 1 (480 max) ? prev_hsize: horizontal size for the preview path horizontal preview size = prev_hsize + 1 (640 max) 31 30 29 28 27 26 25 24 ?????? prev_hsize 23 22 21 20 19 18 17 16 prev_hsize 15 14 13 12 11 10 9 8 ?????? prev_vsize 76543210 prev_vsize
748 32015a?avr32?02/07 AT32AP7001 35.5.8 isi preview decimation factor register register name: pdecf access type: read/write reset value: 0x00000010 ? dec_factor: decimation factor dec_factor is 8-bit width, range is from 16 to 255. values from 0 to 16 do not perform any decimation. 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ???????? 76543210 dec_factor
749 32015a?avr32?02/07 AT32AP7001 35.5.9 isi preview primary fbd register register name: ppfbd access type: read/write reset value: 0x0 ? prev_fbd_addr: base address for preview frame buffer descriptor written with the address of the start of the preview frame buffer queue, reads as a pointer to the current buffer being used. forced to word alignement, ie the 2 lowest bits always read zero. 31 30 29 28 27 26 25 24 prev_fbd_addr 23 22 21 20 19 18 17 16 prev_fbd_addr 15 14 13 12 11 10 9 8 prev_fbd_addr 76543210 prev_fbd_addr
750 32015a?avr32?02/07 AT32AP7001 35.5.10 isi codec dma base address register register name: cdba access type: read/write reset value: 0x0 ? codec_dma_addr: base address for codec dma this register contains codec datapath start address of buffer location. forced to word alignement, ie the 2 lowest bits always read zero. 31 30 29 28 27 26 25 24 codec_dma_addr 23 22 21 20 19 18 17 16 codec_dma_addr 15 14 13 12 11 10 9 8 codec_dma_addr 76543210 codec_dma_addr
751 32015a?avr32?02/07 AT32AP7001 35.5.11 isi color space conversion ycrcb to rgb set 0 register register name: y2r_set0 access type: read/write reset value: 0x6832cc95 ? c3 : color space conversion matrix coefficient c3 c3 element, default step is 1/128, ranges from 0 to 255/128 ? c2 : color space conversion matrix coefficient c2 c2 element, default step is 1/128, ranges from 0 to 255/128 ? c1 : color space conversion matrix coefficient c1 c1 element, default step is 1/128, ranges from 0 to 255/128 ? c0 : color space conversion matrix coefficient c0 c0 element, default step is 1/128, ranges from 0 to 255/128 31 30 29 28 27 26 25 24 c3 23 22 21 20 19 18 17 16 c2 15 14 13 12 11 10 9 8 c1 76543210 c0
752 32015a?avr32?02/07 AT32AP7001 35.5.12 isi color space conversion ycrcb to rgb set 1 register register name: y2r_set1 access type: read/write reset value: 0x00007102 ? c4: color space conversion matrix coefficient c4 c4 element default step is 1/128, ranges from 0 to 512/128 ? yoff: color space conversion luminance default offset 0: no offset 1: offset = 128 ? croff: color space conversion red chrominance default offset 0: no offset 1: offset = 16 ? cboff: color space conversion blue chrominance default offset 0: no offset 1: offset = 16 31 30 29 28 27 26 25 24 ???????? 23 22 21 20 19 18 17 16 ???????? 15 14 13 12 11 10 9 8 ? cboff croff yoff ? ? ? c4 c4
753 32015a?avr32?02/07 AT32AP7001 35.5.13 isi color space conversion rgb to ycrcb set 0 register register name: r2y_set0 access type: read/write reset value: 0x01324145 ? c0: color space conversion matrix coefficient c0 c0 element default step is 1/256, from 0 to 127/256 ? c1: color space conversion matrix coefficient c1 c1 element default step is 1/128, from 0 to 127/128 ? c2: color space conversion matrix coefficient c2 c2 element default step is 1/512, from 0 to 127/512 ? roff: color space conversion red component offset 0: no offset 1: offset = 16 31 30 29 28 27 26 25 24 ???????roff 23 22 21 20 19 18 17 16 -c2 15 14 13 12 11 10 9 8 -c1 76543210 -c0
754 32015a?avr32?02/07 AT32AP7001 35.5.14 isi color space conversion rgb to ycrcb set 1 register register name: r2y_set1 access type: read/write reset value: 0x01245e38 ? c3: color space conversion matrix coefficient c3 c0 element default step is 1/128, ranges from 0 to 127/128 ? c4: color space conversion matrix coefficient c4 c1 element default step is 1/256, ranges from 0 to 127/256 ? c5: color space conversion matrix coefficient c5 c1 element default step is 1/512, ranges from 0 to 127/512 ? goff: color space conversion green component offset 0: no offset 1: offset = 128 31 30 29 28 27 26 25 24 ???????goff 23 22 21 20 19 18 17 16 -c5 15 14 13 12 11 10 9 8 -c4 76543210 -c3
755 32015a?avr32?02/07 AT32AP7001 35.5.15 isi color space conversion rgb to ycrcb set 2 register register name: r2y_set2 access type: read/write reset value: 0x01384a4b ? c6: color space conversion matrix coefficient c6 c6 element default step is 1/512, ranges from 0 to 127/512 ? c7: color space conversion matrix coefficient c7 c7 element default step is 1/256, ranges from 0 to 127/256 ? c8: color space conversion matrix coefficient c8 c8 element default step is 1/128, ranges from 0 to 127/128 ? boff: color space conversion blue component offset 0: no offset 1: offset = 128 31 30 29 28 27 26 25 24 ???????boff 23 22 21 20 19 18 17 16 -c8 15 14 13 12 11 10 9 8 -c7 76543210 -c6
756 32015a?avr32?02/07 AT32AP7001 36. debug and test 36.1 features ? ieee1149.1 compliant jtag and boundary scan ? direct memory access and programming capabilities through jtag interface ? extensive on-chip debug features in compliance with ieee-isto 5001-2003 (nexus 2.0) class 3 ? auxiliary port for high-speed trace information ? hardware support for 6 program and 2 data breakpoints ? unlimited number of softw are breakpoints supported ? advanced program, data, ownership, and watchpoint trace supported 36.2 jtag interface access to debug and test features is provided through a ieee1149.1 co mpliant jtag interface, using the pins shown in table 36-1 on page 756 . the jtag is a synchronous, serial protocol, which allows several devices on a circuit board to be accessed through a common jtag port. the clock signal tck and control signal tms is common to all devices, while the data output tdo is chained to the data input tdi of the next device in the jtag chain, effectively fo rming one long scan chain. devices are addressed through their position in the jtag chain. each jtag device contains a tap controller, which can be navigated through the tms pin. the state of the tap controller determines whether the serial data on tdi is a jtag instruction or jtag data. a number of serial data registers can be selected according to which jtag instruc- tion is loaded. the avr32 jtag has a 5-bit instruction register, which selects data registers of varying length. the implemented set of jtag instructio ns provides the following capabilities: ? ieee1149.1 compliant boundary-scan for testing interconnections between devices on a pcb. ? internal and external memory programming ? access to on-chip debug mechanisms ? access to production test mechanisms production test specific features are described only in the test and programming technical ref- erence manual. other features are additionally introduced below. table 36-1. jtag pins pin direction description trst_n input asynchronous reset for the tap controller and jtag registers tck input test clock. data is driven on falling edge, sampled on rising edge. tms input test mode select tdi input test data in tdo output test data out
757 32015a?avr32?02/07 AT32AP7001 figure 36-1. avr32 jtag connections 36.3 public jtag instructions the following public (standard-defined) jtag instructions are provided: ?idcode ? sample_preload ? extest ?intest ? runbist ?clamp ? bypass the idcode is the default instruction loaded into the jtag on power-up or after a jtag reset. this selects the 32-bit jtag idcode register, unique to eac h jtag device. for AT32AP7001 avr32 device jtag data registers tap controller tck tms tdi tdo instruction register id register by- pass reset register memory access boundary scan chain cpu internal memory caches ocd registers external bus interface pins and analog blocks instruction register scan enable data register scan enable nexus access jtag tap trst_n boundary scan enable jtag device jtag device jtag master trst_n tck tms tdi tdo tdi tdo external memory hsb
758 32015a?avr32?02/07 AT32AP7001 this code is 0xr1e8203f, where r is the revisi on number of the device: rev a = 0x0, b = 0x1, etc. bypass selects the 1-bit bypass regi ster as data register. device s in a jtag chain should nor- mally be placed in bypass when not be ing addressed by the jtag master. the other instructions are used by boundary-scan, which allows testing pcb interconnections by scanning known data to the device pins, or samplin g data driven from other circuits on the pcb. for operation of these instructions, please see the test and programming technical reference manual. 36.4 memory programming the memory_access jtag instruction gives the user access to the hsb bus through the jtag interface. the physical address and the direction bit (read/write) is scanned into the jtag, followed by scanning out the read data or scanning in the write data, depending on the direction of the transfer. any physical memory address can be read or written, allowing internal memories to be written in the same way as when accessed by the cpu. similarly, external memories can be accessed thro ugh the external bus interface (ebi). a polling mechanism pro- vides the jtag master with status information, indicating when the memory operation is complete. the memory_block_access command allows fo r a burst mode memory access through jtag. this command automatically repeats a previous memory_access command, with automatic incrementation of the address. thus only data needs to be scanned in or out, giving negligible protocol overhead on the jtag interface. the jtag master can use the crc check feature described in section 36.5.1.6 on page 761 to automatically calculate the crc-32 value of the programmed memory contents, to ensure that no transmission or programming errors have occurred. when loading a new program to memory, t he cpu should be kept reset by the avr_reset jtag command. if the cpu executes a partially loaded program, unpredictable results may occur, and the program may be corrupted. 36.5 debugging debugging on the AT32AP7001 is facilitated by a powerful on -chip debug (ocd) system. the user accesses this through an external debug tool which connects to the jtag port and the aux- iliary (aux) port. the aux port is primarily used for trace functi ons, and a jtag-based debugger is sufficient for basic debugging. the debug system is based on the nexus 2.0 standard, class 3, which includes: ? basic run-time control ? program breakpoints ? data breakpoints ?program trace ? ownership trace ? data trace ? run-time direct memory access in addition to the mandatory nexus debug features, the AT32AP7001 implements several useful ocd features, such as:
759 32015a?avr32?02/07 AT32AP7001 ? debug communication channel between cpu and jtag ? run-time pc monitoring ? crc checking ? nanotrace ? software quality analysis support the ocd features are controlled by ocd regist ers, which can be accessed by jtag when the nexus_access jtag instruction is loaded. the cpu can also access ocd registers directly using mtdr/mfdr instructions in any privileged mode. the ocd registers are implemented based on the recommendations in the nexus 2.0 standard, and are detailed in the ocd technical ref- erence manual. figure 36-2. on-chip debug block diagram 36.5.1 jtag-based debug features a debugger can control all ocd features by writing ocd registers over the jtag interface. many of these do not depend on output on the aux port, allowing a jtag-based debugger to be used. on-chip debug jtag debug pc debug instruction cpu breakpoints program trace data trace ownership trace watchpoints transmit queue aux jtag memory nanotrace module service access bus memory interface data cache
760 32015a?avr32?02/07 AT32AP7001 a jtag-based debugger should connect to the device through a standard 10-pin idc connector as described in the ocd technical reference manual. figure 36-3. jtag-based debugger 36.5.1.1 debug communication channel the debug communication channel (d cc) consists of a pair ocd registers with associated handshake logic, accessible to both cpu an d jtag. the registers can be used to exchange data between the cpu and the jtag master, both runtime as well as in debug mode. 36.5.1.2 breakpoints one of the most fundamental debug features is the abilit y to halt the cpu, to examine registers and the state of the system. this is accomplish ed by breakpoints, of which many types are available: ? unconditional breakpoints halt the cpu immediately. breakpoints are set by writing the ocd registers directly via jtag. ? program breakpoints halt the cpu when a specific address in the program is executed. ? data breakpoints halt the cpu when a specific memory address is read or written, allowing variables to be watched. ? software breakpoints halt the cpu when the breakpoint instruction is executed. avr32 jtag-based debug tool pc jtag low speed 10-pin idc
761 32015a?avr32?02/07 AT32AP7001 when a breakpoint triggers, the cpu enters debug mode, and the d bit in the status register is set. this is a privileged mode with dedicated return address and return status registers. all privi- leged instructions are permitted. debug mode can be entered as either ocd mode, running instructions from jtag, or monitor mode, running instructions from program memory. 36.5.1.3 ocd mode when a breakpoint triggers, the cpu enters ocd mode, and instructions are fetched from the debug instruction ocd register. each time this register is written by jtag, the instruction is executed, allowing the jtag to execute cpu instructions directly. the jtag master can e.g. read out the register file by issuing mtdr instructions to the cpu, writing each register to the debug communication channel ocd registers. 36.5.1.4 monitor mode since the ocd registers are directly accessible by the cpu, it is possible to build a software- based debugger that runs on the cpu itself. setting the monitor mode bit in the development control register causes the cpu to enter monitor mode instead of ocd mode when a breakpoint triggers. monitor mode is similar to ocd mode, except that instructions are fetched from the debug exception vector in regular program memory, instead of issued by jtag. 36.5.1.5 direct memory access direct memory access can be accomplished as described above using the memory_access jtag instruction. it is not ne cessary to halt the cpu when using this mechanism, so the memo- ries can be examined on-the-fly without disturbing the program. it is also possible to access memory by using ocd registers, as described in the nexus standard. 36.5.1.6 cyclic redundancy check (crc) the memory access ocd registers can additionally be used to automatically calculate the crc of a block of data in memory. the ocd will then read out each word in the specified memory block and report the crc32-value in an ocd register. 36.5.1.7 nanotrace nanotrace is an avr32-specific feature, in which trace data is output to memory instead of the aux port. this allows the trace data to be extracted by jtag memory_access, enabling trace features for jtag-based debuggers. the user must write ocd registers to configure the address and size of the memory block to be us ed for nanotrace. the nanotrace buffer can be anywhere in the physical address range, including internal and external ram, through the ebi. this area may not be used by the application running on the cpu. the nanotrace access error protection mechanism can trigger a reset or br eakpoint if the application erroneously accesses the nanotrace buffer. 36.5.1.8 program counter monitoring normally, the cpu would need to be halted for a jtag-based debugger to examine the current pc value. however, the AT32AP7001 also proves a debug program counter ocd register, where the debugger can continuously read the current pc without affecting the cpu. this allows the debugger to generate a simple statistic of the time spent in various areas of the code, easing code optimization.
762 32015a?avr32?02/07 AT32AP7001 36.5.2 aux-based debug features utilizing the auxiliary (aux) port gives a ccess to a wide range of advanced debug features. of prime importance are the trace features, which allow an external debugger to receive continuous information on the program execution in the cpu. additionally, event in and event out pins allow external events to be correlated with the program flow. the aux port contains a number of pins, as shown in table 36-2 . these are multiplexed with pio lines, and must explicitly be enabled by writing ocd registers before the debug session starts. the aux port is mapped to two different locations, selectable by ocd registers, minimiz- ing the chance that the aux port will nee d to be shared wit h an application. debug tools utilizing the aux port should connec t to the device throug h a nexus-compliant mic- tor-38 connector, as described in the ocd technical reference manual. this connector includes the jtag signals and the reset_n pin, giving full access to the programming and debug features in the device. table 36-2. auxiliary port signals signal direction description mcko output trace data output clock mdo[5:0] output trace data output mseo[1:0] output trace frame control evti_n input event in evto_n output event out
763 32015a?avr32?02/07 AT32AP7001 figure 36-4. aux+jtag based debugger 36.5.2.1 trace operation trace features are enabled by writing ocd registers by jtag. the ocd extracts the trace infor- mation from the cpu, compresses this information and formats it into variable-length messages according to the nexus standard. the messages are buffered in a 16-frame transmit queue, and are output on the aux port one frame at a time. the trace features can be configured to be very selective, to reduce the bandwidth on the aux port. in case the transmit queue overflows, er ror messages are produced to indicate loss of data. the transmit queue module can optionally be configured to halt the cpu when an overflow occurs, to prevent the loss of messages, at the expense of longer run-time for the program. 36.5.2.2 program trace program trace allows the debugger to continuously monitor the program execution in the cpu. program trace messages are generated for every branch in the program, and contains com- pressed information, which allows the debugger to correlate the message with the source code to identify the branch instruction and target address. avr32 aux+jtag debug tool pc jtag low speed aux high speed mictor38 trace buffer
764 32015a?avr32?02/07 AT32AP7001 36.5.2.3 data trace data trace outputs a message every time a specific location is read or written. the message contains information about the type (read/write) and size of the access, as well as the address and data of the accessed location. the AT32AP7001 contains two data trace channels, each of which are controlled by a pair of ocd registers which determine the range of addresses (or sin- gle address) which should produce data trace messages. 36.5.2.4 ownership trace program and data trace operate on virtual addresses. in cases where an operating system runs several processes in overlapping virtual memory segments, the ownership trace feature can be used to identify the process switch. when the os activates a process, it will write the process id number to an ocd register, which produces an ownership trace message, allowing the debug- ger to switch context for the subsequent progra m and data trace messages. as the use of this feature depends on the software running on the cpu, it can also be used to extract other types of information from the system. 36.5.2.5 watchpoint messages the breakpoint modules normally used to generate program and data breakpoints can also be used to generate watchpoint messages, allowing a debugger to monitor program and data events without halting the cpu. watchpoints can be enabled independently of breakpoints, so a breakpoint module can optionally halt the cpu w hen the trigger condition occurs. data trace modules can also be configured to produce watc hpoint messages instead of regular data trace messages. 36.5.2.6 event in and event out pins the aux port also contains an event in pin (evti_n) and an event out pin (evto_n). evti_n can be used to trigger a breakpoint when an external event occurs. it can also be used to trigger specific program and data trace synchronization messages, allowing an external event to be correlated to the program flow. when the cpu enters debug mode, a debug status message is transmitted on the trace port. all trace messages can be timestamped when they are received by the debug tool. however, due to the latency of the trans mit queue buffering, the timest amp will not be 100% accurate. to improve this, evto_n can toggle every time a message is inserted into the transmit queue, allowing trace messages to be timestamped prec isely. evto_n can also toggle when a break- point module triggers, or when the cpu enters debug mode, for any reason. this can be used to measure precisely when the respective internal event occurs. 36.5.2.7 software quality analysis (sqa) software quality analysis (sqa) deals with two important issues regarding embedded software development. code coverage involves identifying untested parts of the embedded code, to improve test procedures and thus the quality of the released software. performance analysis allows the developer to precisely quantify the time spent in various parts of the code, allowing bottlenecks to be identified and optimized. program trace must be used to accomplish these tasks without instrumenting (altering) the code to be examined. however, traditional program trace cannot reconstruct the current pc value without correlating the trace information with the source code, which cannot be done on-the-fly.
765 32015a?avr32?02/07 AT32AP7001 this limits program trace to a relatively short time segment, determined by the size of the trace buffer in the debug tool. the ocd system in AT32AP7001 extends program trace with sqa capabilities, allowing the debug tool to reconstruct the pc value on-the-f ly. code coverage and performance analysis can thus be reported for an unlimited execution sequence.
766 32015a?avr32?02/07 AT32AP7001 37. boot sequence this chapter summarizes the boot sequence of the AT32AP7001. the behaviour after power-up is controlled by the power manager. 37.1 starting of clocks after power-up, the device will be held in a reset state by the power-on reset circuitry, until the power has stabilized throughout the device. once the power has stabilized, the device will use the xin0 pin as clock source. xin0 can be connect ed either to an external clock, or a crystal. the oscen_n pin is connected either to vdd or gnd to inform the power manager on how the xin0 pin is connected. if xin0 receives a signal from a crystal, dedicated circuitry in the power manager keeps the part in a reset state until the oscillator co nnected to xin0 has settled. if xin0 receives an external clock, no such settling delay is applied. on system start-up, the plls are disabled. all clocks to all modules are running. no clocks have a divided frequency, all parts of the system recieves a clock with the same frequency as the xin0 clock. 37.2 fetching of initial instructions after reset has been released, the avr32ap cpu starts fetching instructions from the reset address, which is 0xa000_0000. this address lies in the p2 segment, which is non-translated, non-cacheable, and permanently mapped to the physical address range 0x0000_0000 to 0x2000_0000. this means that the instruction being fetched from virtual address 0xa000_0000 is being fetched from physical address 0x0000_0000. physical address 0x0000_0000 is mapped to ebi sram cs0. this is the external memory the device boots from. the code read from the sram cs0 memory is free to configure the system to use for example the plls, to divide the frequency of the clock routed to some of the peripherals, and to gate the clocks to unused peripherals.
767 32015a-avr32-02/07 AT32AP7001 38. mechanical characteristics - tbd 38.1 avr32ap7001 38.1.1 thermal considerations 38.1.1.1 thermal data table 38-1 summarizes the thermal resistance data depending on the package. 38.1.1.2 junction temperature the average chip-junction temperature, t j , in c can be obtained from the following: 1. 2. where: ? ja = package thermal resistance, junction-to-ambient (c/w), provided in table 38-4 on page 769 . ? jc = package thermal resistance, junction-to-ca se thermal resistance (c/w), provided in table 38-4 on page 769 . ? heat sink = cooling device thermal resistance (c/w), provided in the device datasheet. ?p d = device power consumption (w) estimated from data provided in the power consumption section, in the next chapter. ?t a = ambient temperature (c). from the first equation, the user can derive the estimated lifetime of the chip and decide if a cooling device is necessary or not. if a coolin g device is to be fitted on the chip, the second equation should be used to compute the resulting average chip-junction temperature t j in c. table 38-1. thermal resistance data symbol parameter condition package typ unit ja junction-to-ambient thermal resistance still air qfp208 tbd c/w jc junction-to-case thermal resistance qfp208 tbd t j t a p d ja () + = t j t a p ( d ( heatsink jc )) ++ =
768 32015a-avr32-02/07 AT32AP7001 38.1.2 package drawings figure 38-1. 208-pin qfp package drawing
769 32015a-avr32-02/07 AT32AP7001 38.1.3 soldering profile table 38-6 gives the recommended soldering profile from j-std-20. note: it is recommended to apply a soldering temperature higher than 250c. a maximum of three reflow passes is allowed per component. table 38-2. soldering information pin land tbd solder mask opening tbd table 38-3. device and 208-qfp package maximum weight tbd mg table 38-4. 208-qfp package characteristics moisture sensitivity level tbd table 38-5. package reference jedec drawing reference tbd jesd97 classification tbd table 38-6. soldering profile profile feature green package average ramp-up rate (217c to peak) tbd preheat temperature 175c 25c tbd temperature maintained above 217c tbd time within 5 c of actual peak temperature tbd peak temperature range tbd ramp-down rate tbd time 25 c to peak temperature tbd
770 32015a?avr32?02/07 AT32AP7001 39. electrical characteristics 39.1 absolute maximum ratings 39.2 dc characteristics the following characteristics are applicable to the operating temperature range: t a = -40c to 85c, unless otherwise spec- ified and are certified for a junction temperature up to t j = 100c. table 39-1. absolute maximum ratings* operating temperature (industrial)............ -40 c to +85 c *notice: stresses beyond those listed under ?absolute maximum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational se ctions of this specification is not implied. exposure to absolute maximum rating conditions for extended periods may affect device reli- ability. storage temperature ............................... -60c to +150c voltage on input pins with respect to ground-0.3v to vddio + 0.3v (+3.9v max) maximum operating voltage (vddcore, vddosc, vddpll and vddusb) ..... 1.95v maximum operating voltage (vddio ) ..................................................................... 3.6v total dc output current on all i/o lines ................ 350 ma table 39-2. dc characteristics symbol parameter conditions min typ max units v vddcore dc supply core 1.65 1.95 v v vddbu dc supply backup 1.65 1.95 v vddosc dc supply oscillator 1.65 1.95 v v vddpll dc supply pll 1.65 1.95 v v vddusb dc supply usb 1.65 1.95 v v vddio dc supply peripheral i/os 3.0 3.6 v v il input low-level voltage -0.3 +0.8 v v ih input high-level voltage 2.0 v vddio +0.3 v v ol output low-level voltage i ol = 8 ma 0.4 v v oh output high-level voltage i oh = 8 ma v vddio -0.4 v i il input leakage current, pin low pullup resistors disabled 1 a i ih input leakage current, pin high pullup resistors disabled 1 a r pulluppio pull-up resistance on pio pins 190 kohm r pullupctrl pull-up resistance on control and jtag pins 13 kohm
771 32015a?avr32?02/07 AT32AP7001 39.3 power consumption ? typical power consumption of plls , slow clock and main oscillator. ? power consumption of power supply in active mode. ? power consumption by peripheral: calculated as the difference in current measurement after having enabled then disabled the corresponding clock. 39.3.1 power consumption versus modes the values in table 39-3 and table 39-4 on page 772 are measured values of power consump- tion with operating conditions as follows: ?v vddio = 3.3v ?v vddcore = v vddusb = v vddpll = v vddosc = 1.8v ?t a = 25 c ? there is no consumption on the i/os of the device figure 39-1. measures schematics i o output current 8ma i sc static current on v vddcore = 1.8v, cpu = 0 hz t a =25c 300 a all inputs driven; reset_n=1 t a =85c 5000 table 39-2. dc characteristics (continued) vddcore vddusb vddpll vddosc amp
772 32015a?avr32?02/07 AT32AP7001 these figures represent the power consum ption measured on the power supplies. note: 1. the value is measured at best case conditi on. actual current consumption will vary depending on the application. . note: 1. these numbers are relative to the actual cpu clock frequency, using the standard bus divi- sion: hsb and pbb divided by two. pba divided by four. table 39-3. typical power consumption for different operating modes mode conditions typical consumption unit active (1) all peripheral clocks deactivated. 500 a/mhz idle all peripheral clocks activated. 480 frozen all peripheral clocks activated. 280 standby all peripheral clocks activated. 80 table 39-4. power consumption by peripheral in active mode peripheral consumption unit pio controller 3 a/mhz (1) usart 3 usb 9 macb 31 smc 1 sdramc 1 ac97 5 isi 3 audio dac 1 lcdc 31 twi 1 spi 1 mci 7 ssc 3 timer counter channels 1
773 32015a?avr32?02/07 AT32AP7001 39.4 clock characteristics these parameters are given in the following conditions: v vddcore = 1.8v, ambient temperature = 25c, unless otherwise specified. 39.4.1 cpu clock characteristics note: 1. the bus clocks in the system should be divided, relative to the cpu, to be sure they operate in their specified range. t he hsb and pbb bus clocks should be divided by two and the pba bus clock should be divided by four relative to the cpu clock. the division factor of the buses can be set by programming the power manager register cksel. figure 39-2 and figure 39-3 shows typical maximum cpu frequencies based on a selection of samples from different lots. figure 39-2. cpu clock frequency vs. v vddcore (typical) table 39-5. guaranteed cpu clock frequencies. symbol parameter conditions min max units 1/(t cpcpu ) cpu clock frequency (1) te m p = 8 5 c, v vddcore = 1.8v tbd mhz 1/(t cpcpu ) cpu clock frequency (1) te m p = 8 5 c, v vddcore = 1.65v tbd mhz 8 5 c 25 c -40 c 100 120 140 160 1 8 0 200 220 240 1.6 1.65 1.7 1.75 1. 8 1. 8 5 1.9 1.95 2 v v ddcore ( v ) fre qu ency (mhz)
774 32015a?avr32?02/07 AT32AP7001 figure 39-3. cpu clock frequency vs. temperature (typical) 39.4.2 xin clock characteristics note: 1. these characteristics apply only when the osc illators arein bypass mode (i.e., when oscen_n is 1) 39.4.3 reset_n characteristics 1.95 v 1.90 v 1. 8 5 v 1. 8 0 v 1.75 v 1.70 v 1.65 v 100 120 140 160 1 8 0 200 220 240 -60 -40 -20 0 20 40 60 8 0100 temperat u re (c) fre qu ency (mhz) table 39-6. xin clock electrical characteristics symbol parameter conditions min max units 1/(t cpxin ) xin clock frequency (1 50.0 mhz table 39-7. reset_n electrical characteristics symbol parameter conditions min max units t reset reset_n minimum pulse length 50 ns
775 32015a?avr32?02/07 AT32AP7001 39.5 crystal oscillat or characteristics the following characteristics are applicabl e to the operating temperature range: t a = -40c to 85c and worst case of power supply, unless otherwise specified. 39.5.1 32 khz oscillator characteristics note: 1. r s is the equivalent series resistance, c l is the equivalent load capacitance. 39.5.2 main oscillators characteristics notes: 1. c s is the shunt capacitance 39.5.3 pll characteristics note: 1. startup time depends on pll rc filter. a calculation tool is provided by atmel. table 39-8. 32 khz oscillator characteristics symbol parameter conditions min typ max unit 1/(t cp32khz ) crystal oscillator frequency 32 768 hz t st startup time v ddosc = 1.8 v r s = tbd k , c l = tbd pf (1) 1000 ms table 39-9. main oscillator characteristics symbol parameter conditions min typ max unit 1/(t cpmain ) crystal oscillator frequency 10 27 mhz c l1 , c l2 internal load capacitance (c l1 = c l2 ) tbd pf t st startup time 4ms table 39-10. phase lock loop characteristics symbol parameter conditions min typ max unit f out output frequency pll:pllopt = 0b100 80 133 mhz pll:pllopt = 0b110 tbd tbd mhz f in input frequency tbd tbd mhz
776 32015a?avr32?02/07 AT32AP7001 39.6 usb transceiver characteristics 39.6.1 electrical characteristics 39.6.2 switching characteristics table 39-11. electrical parameters symbol parameter conditions min typ max unit input levels v il low level tbd v v ih high level tbd v v di differential input sensivity |(d+) - (d-)| tbd v v cm differential input common mode range tbd tbd v c in transceiver capacitance capacitance to ground on each line tbd pf i hi-z state data line leakage 0v < v in < 3.3v tbd tbd a r ext recommended external usb series resistor in series with each usb pin with 5% tbd output levels v ol low level output measured with r l of 1.425 k tied to 3.6v tbd tbd v v oh high level output measured with r l of 14.25 k tied to gnd tbd tbd v v crs output signal crossover voltage measure conditions described in figure 39-4 tbd tbd v table 39-12. in full speed symbol parameter conditions min typ max unit t fr transition rise time c load = tbd pf tbd tbd ns t fe transition fall time c load = tbd pf tbd tbd ns t frfm rise/fall time matching c load = tbd pf tbd tbd % table 39-13. in high speed symbol parameter conditions min typ max unit t fr transition rise time c load = tbd pf tbd tbd ns t fe transition fall time c load = tbd pf tbd tbd ns t frfm rise/fall time matching tbd tbd %
777 32015a?avr32?02/07 AT32AP7001 figure 39-4. usb data signal rise and fall times 10% 10% 90% v crs t r t f differential data lines rise time fall time fosc = 6 mhz/750khz r ext = 39 ohms c load buffer (b) (a)
778 32015a?avr32?02/07 AT32AP7001 39.7 ac characteristics - tbd 39.8 ebi timings these timings are given for worst case process, t = 85 c, vddcore = 1.65v, vddio = 3v and 50 pf load capacitance. note: 1. hold length = total cycle duration - setup duration - pulse duration. ?hold length? is for ?ncs rd hold length? or ?nrd hold length?. table 39-14. smc read signals with hold settings symbol parameter min units nrd controlled (read_mode = 1) smc 1 data setup before nrd high -5.5 ns smc 2 data hold after nrd high -2.8 smc 3 nrd high to nbs0/a0 change (1) nrd hold length * t cpmck - 1.3 smc 4 nrd high to nbs1 change (1) nrd hold length * t cpmck - 1.3 smc 5 nrd high to nbs2/a1 change (1) nrd hold length * t cpmck - 1.3 smc 6 nrd high to nbs3 change (1) nrd hold length * t cpmck - 1.3 smc 7 nrd high to a2 - a25 change (1) nrd hold length * t cpmck - 1.9 smc 8 nrd high to ncs inactive (1) (nrd hold length - ncs rd hold length) * t cpmck - 1.0 smc 9 nrd pulse width nrd pulse length * t cpmck - 0.1 nrd controlled (read_mode = 0) smc 10 data setup before ncs high -2.5 ns smc 11 data hold after ncs high -2.5 smc 12 ncs high to nbs0/a0 change (1) ncs rd hold length * t cpmck - 5.6 smc 13 ncs high to nbs0/a0 change (1) ncs rd hold length * t cpmck - 5.6 smc 14 ncs high to nbs2/a1 change (1) ncs rd hold length * t cpmck - 5.6 smc 15 ncs high to nbs3 change (1) ncs rd hold length * t cpmck - 5.6 smc 16 ncs high to a2 - a25 change (1) ncs rd hold length * t cpmck - 0.1 smc 17 ncs high to nrd inactive (1) ncs rd hold length - nrd hold length)* t cpmck - 4.3 smc 18 ncs pulse width ncs rd pulse length * t cpmck - 5.5
779 32015a?avr32?02/07 AT32AP7001 note: 1. hold length = total cycle duration - setup duration - pulse duration. ?hold length? is for ?ncs wr hold length? or ?nwe hold length" table 39-15. smc read signals with no hold settings symbol parameter min units nrd controlled (read_mode = 1) smc 19 data setup before nrd high -3.3 ns smc 20 data hold after nrd high -2.9 nrd controlled (read_mode = 0) smc 21 data setup before ncs high -2.8 ns smc 22 data hold after ncs high -2.6 table 39-16. smc write signals with hold settings symbol parameter min units nrd controlled (read_mode = 1) smc 23 data out valid before nwe high (nwe pulse length - 1) * t cpmck - 10.9 ns smc 24 data out valid after nwe high (1) nwe hold length * t cpmck - 1.5 smc 25 nwe high to nbs0/a0 change (1) nwe hold length * t cpmck - 1.0 smc 26 nwe high to nbs1 change (1) nwe hold length * t cpmck - 1.0 smc 29 nwe high to nbs2/a1 change (1) nwe hold length * t cpmck - tbd smc 30 nwe high to nbs3 change (1) nwe hold length * t cpmck - tbd smc 31 nwe high to a2 - a25 change (1) nwe hold length * t cpmck - 1.6 smc 32 nwe high to ncs inactive (1) (nwe hold length - n cs wr hold length)* t cpmck - 0.7 smc 33 nwe pulse width nwe pulse length * t cpmck nrd controlled (read_mode = 0) smc 34 data out valid before ncs high (ncs wr pulse length - 1)* t cpmck - 0.4 ns smc 35 data out valid after ncs high (1) ncs wr hold length * t cpmck - 1.2 smc 36 ncs high to nwe inactive (1) (ncs wr hold length - nwe hold length)* tc pmck - 4.9
780 32015a?avr32?02/07 AT32AP7001 figure 39-5. smc signals for ncs controlled accesses. table 39-17. smc write signals with no hold settings (nwe controlled only). symbol parameter min units smc 37 nwe rising to a2-a25 valid 3.6 ns smc 38 nwe rising to nbs0/a0 valid 3.7 smc 39 nwe rising to nbs1 change 3.7 smc 40 nwe rising to a1/nbs2 change 3.7 smc 41 nwe rising to nbs3 change 3.7 smc 42 nwe rising to ncs rising 3.8 smc 43 data out valid before nwe rising (nwe pulse length - 1) * t cpmck - 4.9 smc 44 data out valid after nwe rising 3.8 smc 45 nwe pulse width nwe pulse length * t cpmck mck internal signal nrd ncs d0 - d31 nwr a2-a25 a0/a1/nbs[3:0] smc 8 smc 9 smc 6 smc 7 smc 6 smc 7 smc 10 smc 11 smc 53 smc 54 smc 43 smc 26 smc 27 smc 1 smc 32 smc 31 smc 6 smc 8 smc 9 smc 42 smc 41 smc 33 smc 40 smc 39 smc 34 smc 7 smc 30 smc 29 smc 28 smc 34 smc 25 smc 24 smc 33 smc 32 smc 31 smc 30 smc 29 smc 28 smc 34 smc 55 smc 32 smc 31 smc 30 smc 29 smc 28 smc 5 smc 4 smc 3 smc 2 read cycle with no hold read cycle with hold write cycle with hold
781 32015a?avr32?02/07 AT32AP7001 figure 39-6. smc signals for nrd and nrw controlled accesses. 39.8.1 sdram signals these timings are given for 10 pf load on sdck and 50 pf on other signals. mck internal signal nrd ncs d0 - d31 nwr a2-a25 a0/a1/nbs[3:0] smc 1 smc 21 smc 8 smc 9 smc 6 smc 7 smc 6 smc 10 smc 11 smc 37 smc 38 smc 62 smc 56 smc 43 smc 61 smc 22 smc 6 smc 9 smc 8 smc 6 smc 15 smc 16 smc 10 smc 44 smc 45 smc 11 smc 51 smc 21 smc 5 smc 4 smc 3 smc 2 smc 22 smc 35 smc 36 smc 20 smc 19 smc 18 smc 17 smc 23 smc 60 smc 59 smc 58 smc 57 smc 64 smc 23 smc 13 smc 14 smc 20 smc 19 smc 18 smc 17 smc 52 smc 49 smc 48 smc 47 smc 46 smc 50 smc 43 smc 63 read cycle with no hold write cycle with no hold read cycle with hold write cycle with hold table 39-18. sdram clock signal. symbol parameter max units 1/(t cpsdck ) sdram controller clock frequency tbd mhz
782 32015a?avr32?02/07 AT32AP7001 table 39-19. sdram clock signal. symbol parameter min units sdramc 1 sdcke high before sdck rising edge 6.8 ns sdramc 2 sdcke low after sdck rising edge 5.8 sdramc 3 sdcke low before sdck rising edge 6.8 sdramc 4 sdcke high after sdck rising edge 6.2 sdramc 5 sdcs low before sdck rising edge 6.7 sdramc 6 sdcs high after sdck rising edge 5.9 sdramc 7 ras low before sdck rising edge 6.7 sdramc 8 ras high after sdck rising edge 6.9 sdramc 9 sda10 change before sdck rising edge 6.9 sdramc 10 sda10 change after sdck rising edge 5.7 sdramc 11 address change before sdck rising edge 6.4 sdramc 12 address change after sdck rising edge 4.5 sdramc 13 bank change before sdck rising edge 6.6 sdramc 14 bank change after sdck rising edge 5.2 sdramc 15 cas low before sdck rising edge 7.1 sdramc 16 cas high after sdck rising edge 5.9 sdramc 17 dqm change before sdck rising edge 6.5 sdramc 18 dqm change after sdck rising edge 4.6 sdramc 19 d0-d15 in setup before sdck rising edge 2.3 sdramc 20 d0-d15 in hold after sdck rising edge 3.9 sdramc 21 d16-d31 in setup before sdck rising edge 0.9 sdramc 22 d16-d31 in hold after sdck rising edge 4.0 sdramc 23 sdwe low before sdck rising edge 6.5 sdramc 24 sdwe high after sdck rising edge 7.0 sdramc 25 d0-d15 out valid before sdck rising edge 6.2 sdramc 26 d0-d15 out valid after sdck rising edge 4.1 sdramc 27 d16-d31 out valid befo re sdck rising edge 6.2 sdramc 28 d16-d31 out valid a fter sdck rising edge 4.5
783 32015a?avr32?02/07 AT32AP7001 figure 39-7. sdramc signals relative to sdck. ras a0 - a9, a11 - a13 d0 - d15 read sdck sda10 d0 - d15 to write sdramc 1 sdcke sdramc 2 sdramc 3 sdramc 4 sdcs sdramc 5 sdramc 6 sdramc 5 sdramc 6 sdramc 5 sdramc 6 sdramc 7 sdramc 8 cas sdramc 15 sdramc 16 sdramc 15 sdramc 16 sdwe sdramc 23 sdramc 24 sdramc 9 sdramc 10 sdramc 9 sdramc 10 sdramc 9 sdramc 10 sdramc 11 sdramc 12 sdramc 11 sdramc 12 sdramc 11 sdramc 12 ba0/ba1 sdramc 13 sdramc 14 sdramc 13 sdramc 14 sdramc 13 sdramc 14 sdramc 17 sdramc 18 sdramc 17 sdramc 18 dqm0 - dqm3 sdramc 19 sdramc 20 d16 - d31 read sdramc 21 sdramc 22 sdramc 25 sdramc 26 d16 - d31 to write sdramc 27 sdramc 28
784 32015a?avr32?02/07 AT32AP7001 40. ordering information figure 40-1. ordering information ordering code package package type packing temperature operating range AT32AP7001-alut qfp208 green tray industrial (-40 c to 85 c)
785 32015a?avr32?02/07 AT32AP7001 41. errata 41.1 rev. c 1. spi fdiv option does not work selecting clock signal using fdiv = 1 does not work as specified. fix/workaround do not set fdiv = 1. 2. spi chip select 0 bits field overrides other chip selects the bits field for chip select 0 overrides bits fields for other chip selects. fix/workaround update chip select 0 bits field to the relevant settings before transmit ting with chip selects other than 0. 3. spi lastxfer may be overwritten when peripheral select (ps) = 0, the lastxfer -bit in the transmit data register (tdr) should be internally discared. this fails and may cause problems during dma transfers. transmitting data using the pdc when ps=0, the size of the transferred data is 8- or 16-bits. the upper 16 bits of the tdr will be written to a random value. if chip select active after transfer (csaat) = 1, the behavior of the chip select will be unpredictable. fix/workaround - do not use csaat = 1 if ps = 0 - use gpio to control chip select lines - select ps=1 and store data for pcs and lastxfer for each data in transmit buffer. 4. spi lastxfer ove rrides chip select the lastxfer bit overrides chip select input when ps = 0 and csaat is used. fix/workaround - do not use the csaat - use gpio as chip select input - select ps = 1. transfer 32-bit with correct lastxfer settings. 5. mmc data drite operation with less than 12 bytes is impossible. the data write operation with a number of bytes less than 12 is impossible fix/workaround the pdc counters must always be equal to 12 bytes for data transfers lower than 12 bytes. the blklen or bcnt field are used to specify the real count number. 6. mmc sdio interrupt only works for slot a if 1-bit data bus width and on other slots than slot a, the sdio interrupt can not be cap- tured. fix/workaround use slot a.
786 32015a?avr32?02/07 AT32AP7001 7. psif txen/rxen may disable the transmitter/receiver writing a '0' to rxen will disable the receiver. writing '0' to txen will disable the transmitter. fix/workaround when accessing the ps/2 control register alwa ys write '1' to rxen to keep the receiver enabled, and write '1' to txen to keep the transmitter enabled. 8. psif txrdy interrupt corrupts transfers when writing to the transmit holding register (thr), the da ta will be transfer red to the data shift register immediately, regardless of the state of the data shift register. if a transfer is ongoing, it will be inte rrupted and a new transfer will be st arted with the new data written to thr. fix/workaround use the txempty-interrupt instead of the txrdy-interrupt to update the thr. this ensures that a transfer is completed. 9. pwn counter restarts at 0x0001 the pwn counter restarts at 0x0001 and not 0x0000 as specified. because of this the first pwm period has one more clock cycle. fix/workaround - the first period is 0x0000, 0x0001, ..., period - consecutive periods are 0x0001, 0x0002, ..., period 10. pwm channel interrupt enabling triggers an interrupt when enabling a pwm channel that is configured with center aligned period (calg=1), an interrupt is signalled. fix/workaround when using center aligned mode, enable the channel and read the status before channel interrupt is enabled. 11. pwm update period to a 0 value does not work it is impossible to update a period equal to 0 by the using the pwm update register (pwm_cupd). fix/workaround do not update the pwm_cupd register with a value equal to 0. 12. pwm channel status may be wrong if disabled before a period has elapsed before a pwm period has elapsed, the read channel status may be wrong. the chidx-bit for a pwm channel in the pwm enable register will read '1' fo r one full pwm period even if the channel was disabled before the period elapsed. it will then read '0' as expected. fix/workaround reading the pwm channel status of a disabled channel is only correct after a pwm period 13. twi transfer error without ack if the twi does not receive an ack from a slave during the address+r/w phase, no bits in the status register will be set to indicate this. hence, the transf er will neve r complete.
787 32015a?avr32?02/07 AT32AP7001 fix/workaround to prevent errors due to missing ack, the software should use a timeout mechanism to termi- nate the transfer if this happens. 41.2 rev. b not sampled. 41.3 rev. a not sampled.
788 32015a?avr32?02/07 AT32AP7001 42. datasheet revision history please note that the referring page numbers in th is section are referred to this document. the referring revision in this section are referring to the document revision. 42.1 rev. a 02/07 1. initial revision.
i 32015a?avr32?02/07 AT32AP7001 table of contents features ................ ................ .............. ............... .............. .............. ............ 1 1 part description ......... ................ ................. ................ ................. ............ 2 2 signals description ............ .............. ............... .............. .............. ............ 4 3 power considerations ........ .............. ............... .............. .............. .......... 10 3.1 power supplies ......................................................................................................10 3.2 power supply connections ....................................................................................10 4 package and pinout ................. ................ ................. ................ ............. 12 5 blockdiagram ............. ................ ................. ................ ................. .......... 14 5.1 processor and architecture ....................................................................................15 6 i/o line considerations ...... .............. ............... .............. .............. .......... 19 6.1 jtag pins ...............................................................................................................19 6.2 wake_n pin ............ ................. ................ ................ ................ ................ .............19 6.3 reset_n pin .................. ................ ................ ................ ................ ............. ..........19 6.4 evti_n pin .............................................................................................................19 6.5 twi pins .................................................................................................................1 9 6.6 pio pins .................................................................................................................. 19 7 peripherals ............ .............. .............. ............... .............. .............. .......... 21 7.1 peripheral address map .........................................................................................21 7.2 interrupt request signal map .................................................................................23 7.3 dmac handshake interface map ...........................................................................25 7.4 clock connections .................................................................................................26 7.5 external interrupt pin mapping ...............................................................................27 7.6 nexus ocd aux port connections ........................................................................27 7.7 peripheral multiplexing on io lines .........................................................................28 7.8 peripheral overview ................................................................................................36 8 memories ............... .............. .............. ............... .............. .............. .......... 43 8.1 embedded memories .............................................................................................43 8.2 physical memory map ............................................................................................43 9 power manager ................. ................ ............... .............. .............. .......... 46 9.1 features .................................................................................................................4 6 9.2 description .............................................................................................................46
ii 32015a?avr32?02/07 AT32AP7001 9.3 block diagram ........................................................................................................47 9.4 product dependencies ...........................................................................................48 9.5 functional description ............................................................................................48 9.6 user interface .........................................................................................................59 10 real time counter ... ................ ................ ................. ................ ............. 67 10.1 features ...............................................................................................................67 10.2 description ...........................................................................................................67 10.3 block diagram ......................................................................................................68 10.4 product dependencies .........................................................................................68 10.5 functional description ..........................................................................................69 10.6 user interface .......................................................................................................70 11 external interrupts .......... ................ ................. .............. .............. .......... 78 11.1 features ...............................................................................................................78 11.2 description ...........................................................................................................78 11.3 block diagram ......................................................................................................78 11.4 product dependencies .........................................................................................78 11.5 functional description ..........................................................................................79 11.6 user interface .......................................................................................................80 12 boot sequence ........... ................ ................. ................ ................. .......... 85 12.1 starting of clocks ..................................................................................................85 12.2 fetching of initial instructions ...............................................................................85 13 mechanical characteristics - tb d .................. .............. .............. .......... 86 13.1 thermal considerations .......................................................................................86 13.2 package drawings ...............................................................................................87 13.3 soldering profile ...................................................................................................88 14 electrical characteristics - t bd ............. ................. ................ ............. 89 14.1 absolute maximum ratings ..................................................................................89 14.2 dc characteristics ...............................................................................................89 14.3 power consumption .............................................................................................90 14.4 clock characteristics ............................................................................................92 14.5 crystal oscillator characteristics ..........................................................................93 14.6 usb transceiver characteristics ..........................................................................94 14.7 ac characteristics - tbd .....................................................................................96 14.8 ebi timings - tbd ................................................................................................96
iii 32015a?avr32?02/07 AT32AP7001 15 ordering information .......... .............. ............... .............. .............. .......... 97 16 revision history ....... ................ ................ ................. ................ ............. 98 16.1 rev. f 07/06 .........................................................................................................98 16.2 rev. e 05/06 .........................................................................................................98 16.3 rev. d 04/06 ........................................................................................................98 16.4 rev. c 04/06 ........................................................................................................98 table of contents.......... ................. ................ ................. ................ ........... i
iv 32015a?avr32?02/07 AT32AP7001
32015a?avr32?02/07 ? 2007 atmel corporation . all rights reserved. at m e l ? , logo and combinations thereof, everywhere you are ? , avr ? , and others, are regis- tered trademarks or trademarks of atmel corporation or its subsid iaries. other terms and product names may be trademarks of oth ers. disclaimer: the information in this document is provided in connection with atmel products. no license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of atmel products. except as set forth in atmel?s terms and condi- tions of sale located on atmel? s web site, atmel assumes no liability whatsoever and disclaims any express, implied or statutor y warranty relating to its products including, but not limited to , the implied warranty of merchantability, fitness for a particu lar purpose, or non-infringement. in no event shall atmel be liable for any direct, indirect, conseque ntial, punitive, special or i nciden- tal damages (including, without limitation, damages for loss of profits, business interruption, or loss of information) arising out of the use or inability to use this document, even if at mel has been advised of the possibility of such damages. atmel makes no representations or warranties with respect to the accuracy or co mpleteness of the contents of this document and reserves the rig ht to make changes to specifications and product descriptions at any time without notice. atmel does not make any commitment to update the information contained her ein. unless specifically provided otherwise, atmel products are not suitable for, and shall not be used in, automotive applications. atmel?s products are not int ended, authorized, or warranted for use as components in applications in tended to support or sustain life. atmel corporation atmel operations 2325 orchard parkway san jose, ca 95131, usa tel: 1(408) 441-0311 fax: 1(408) 487-2600 regional headquarters europe atmel sarl route des arsenaux 41 case postale 80 ch-1705 fribourg switzerland tel: (41) 26-426-5555 fax: (41) 26-426-5500 asia room 1219 chinachem golden plaza 77 mody road tsimshatsui east kowloon hong kong tel: (852) 2721-9778 fax: (852) 2722-1369 japan 9f, tonetsu shinkawa bldg. 1-24-8 shinkawa chuo-ku, tokyo 104-0033 japan tel: (81) 3-3523-3551 fax: (81) 3-3523-7581 memory 2325 orchard parkway san jose, ca 95131, usa tel: 1(408) 441-0311 fax: 1(408) 436-4314 microcontrollers 2325 orchard parkway san jose, ca 95131, usa tel: 1(408) 441-0311 fax: 1(408) 436-4314 la chantrerie bp 70602 44306 nantes cedex 3, france tel: (33) 2-40-18-18-18 fax: (33) 2-40-18-19-60 asic/assp/smart cards zone industrielle 13106 rousset cedex, france tel: (33) 4-42-53-60-00 fax: (33) 4-42-53-60-01 1150 east cheyenne mtn. blvd. colorado springs, co 80906, usa tel: 1(719) 576-3300 fax: 1(719) 540-1759 scottish enterprise technology park maxwell building east kilbride g75 0qr, scotland tel: (44) 1355-803-000 fax: (44) 1355-242-743 rf/automotive theresienstrasse 2 postfach 3535 74025 heilbronn, germany tel: (49) 71-31-67-0 fax: (49) 71-31-67-2340 1150 east cheyenne mtn. blvd. colorado springs, co 80906, usa tel: 1(719) 576-3300 fax: 1(719) 540-1759 biometrics/imagin g/hi-rel mpu/ high speed converters/rf datacom avenue de rochepleine bp 123 38521 saint-egreve cedex, france tel: (33) 4-76-58-30-00 fax: (33) 4-76-58-34-80 literature requests www.atmel.com/literature


▲Up To Search▲   

 
Price & Availability of AT32AP7001

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X